]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #52769 - sinkuu:stray_test, r=alexcrichton
authorkennytm <kennytm@gmail.com>
Sat, 28 Jul 2018 08:25:04 +0000 (16:25 +0800)
committerGitHub <noreply@github.com>
Sat, 28 Jul 2018 08:25:04 +0000 (16:25 +0800)
Incorporate a stray test

`liballoc/repeat-generic-slice.rs` doesn't seem to be tested (I think it was intended to be placed in `run-pass`). This PR incorporates the test into `liballoc/tests`.

200 files changed:
src/bootstrap/bin/rustc.rs
src/bootstrap/check.rs
src/bootstrap/doc.rs
src/bootstrap/test.rs
src/bootstrap/tool.rs
src/build_helper/lib.rs
src/ci/docker/dist-various-2/Dockerfile
src/ci/docker/dist-various-2/build-fuchsia-toolchain.sh
src/liballoc/lib.rs
src/liballoc/tests/arc.rs
src/liballoc/tests/btree/set.rs
src/liballoc/tests/lib.rs
src/liballoc/tests/rc.rs
src/liballoc_jemalloc/lib.rs
src/liballoc_system/lib.rs
src/libarena/lib.rs
src/libcore/any.rs
src/libcore/cell.rs
src/libcore/fmt/builders.rs
src/libcore/fmt/mod.rs
src/libcore/iter/iterator.rs
src/libcore/panic.rs
src/libcore/task/context.rs
src/libcore/task/wake.rs
src/libcore/tests/any.rs
src/libcore/tests/hash/mod.rs
src/libcore/tests/intrinsics.rs
src/libcore/tests/mem.rs
src/libcore/tests/option.rs
src/libcore/tests/ptr.rs
src/libcore/tests/result.rs
src/libfmt_macros/lib.rs
src/libgraphviz/lib.rs
src/libpanic_abort/lib.rs
src/libpanic_unwind/lib.rs
src/libproc_macro/lib.rs
src/libprofiler_builtins/lib.rs
src/librustc/hir/map/hir_id_validator.rs
src/librustc/infer/anon_types/mod.rs
src/librustc/infer/error_reporting/need_type_info.rs
src/librustc/infer/outlives/obligations.rs
src/librustc/lib.rs
src/librustc/lint/context.rs
src/librustc/middle/borrowck.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc/traits/object_safety.rs
src/librustc/traits/project.rs
src/librustc/traits/specialize/specialization_graph.rs
src/librustc/ty/context.rs
src/librustc/util/ppaux.rs
src/librustc_allocator/lib.rs
src/librustc_apfloat/lib.rs
src/librustc_asan/lib.rs
src/librustc_borrowck/borrowck/check_loans.rs
src/librustc_borrowck/borrowck/gather_loans/move_error.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_borrowck/lib.rs
src/librustc_codegen_llvm/back/link.rs
src/librustc_codegen_llvm/lib.rs
src/librustc_codegen_utils/lib.rs
src/librustc_data_structures/lib.rs
src/librustc_driver/lib.rs
src/librustc_errors/diagnostic.rs
src/librustc_errors/diagnostic_builder.rs
src/librustc_errors/lib.rs
src/librustc_incremental/lib.rs
src/librustc_lint/lib.rs
src/librustc_llvm/lib.rs
src/librustc_lsan/lib.rs
src/librustc_metadata/dynamic_lib.rs
src/librustc_metadata/lib.rs
src/librustc_mir/borrow_check/borrow_set.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/mutability_errors.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
src/librustc_mir/build/block.rs
src/librustc_mir/build/expr/as_place.rs
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/matches/test.rs
src/librustc_mir/build/mod.rs
src/librustc_mir/lib.rs
src/librustc_mir/transform/elaborate_drops.rs
src/librustc_msan/lib.rs
src/librustc_passes/lib.rs
src/librustc_platform_intrinsics/lib.rs
src/librustc_plugin/lib.rs
src/librustc_privacy/lib.rs
src/librustc_resolve/lib.rs
src/librustc_save_analysis/lib.rs
src/librustc_target/lib.rs
src/librustc_target/spec/aarch64_fuchsia.rs [new file with mode: 0644]
src/librustc_target/spec/aarch64_unknown_fuchsia.rs [deleted file]
src/librustc_target/spec/fuchsia_base.rs
src/librustc_target/spec/mod.rs
src/librustc_target/spec/x86_64_fuchsia.rs [new file with mode: 0644]
src/librustc_target/spec/x86_64_unknown_fuchsia.rs [deleted file]
src/librustc_traits/lib.rs
src/librustc_tsan/lib.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/lib.rs
src/librustdoc/clean/mod.rs
src/librustdoc/core.rs
src/librustdoc/html/highlight.rs
src/librustdoc/html/layout.rs
src/librustdoc/html/render.rs
src/librustdoc/test.rs
src/libserialize/lib.rs
src/libstd/error.rs
src/libstd/ffi/c_str.rs
src/libstd/io/error.rs
src/libstd/io/mod.rs
src/libstd/io/stdio.rs
src/libstd/io/util.rs
src/libstd/net/parser.rs
src/libstd/net/tcp.rs
src/libstd/net/udp.rs
src/libstd/panic.rs
src/libstd/panicking.rs
src/libstd/process.rs
src/libstd/rt.rs
src/libstd/sync/mpsc/mod.rs
src/libstd/sync/mpsc/select.rs
src/libstd/sync/once.rs
src/libstd/sys/cloudabi/thread.rs
src/libstd/sys/redox/process.rs
src/libstd/sys/redox/thread.rs
src/libstd/sys/unix/process/process_common.rs
src/libstd/sys/unix/thread.rs
src/libstd/sys/wasm/thread.rs
src/libstd/sys/windows/thread.rs
src/libstd/sys_common/at_exit_imp.rs
src/libstd/sys_common/backtrace.rs
src/libstd/sys_common/poison.rs
src/libstd/sys_common/thread.rs
src/libstd/thread/mod.rs
src/libsyntax/lib.rs
src/libsyntax/parse/parser.rs
src/libsyntax_ext/lib.rs
src/libsyntax_pos/lib.rs
src/libterm/lib.rs
src/libterm/terminfo/mod.rs
src/libterm/terminfo/parser/compiled.rs
src/libtest/lib.rs
src/libunwind/lib.rs
src/stage0.txt
src/test/ui/bad-crate-name.rs [new file with mode: 0644]
src/test/ui/bad-crate-name.stderr [new file with mode: 0644]
src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr [new file with mode: 0644]
src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.rs [new file with mode: 0644]
src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr [new file with mode: 0644]
src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr [new file with mode: 0644]
src/test/ui/borrowck/borrowck-migrate-to-nll.rs [new file with mode: 0644]
src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr [new file with mode: 0644]
src/test/ui/borrowck/issue-51348-multi-ref-mut-in-guard.rs [new file with mode: 0644]
src/test/ui/error-codes/E0621-does-not-trigger-for-closures.nll.stderr
src/test/ui/generator/generator-with-nll.rs
src/test/ui/generator/generator-with-nll.stderr
src/test/ui/impl-trait/associated-existential-type-generic-trait.rs [new file with mode: 0644]
src/test/ui/impl-trait/associated-existential-type-trivial.rs [new file with mode: 0644]
src/test/ui/impl-trait/associated-existential-type.rs [new file with mode: 0644]
src/test/ui/impl-trait/static-return-lifetime-infered.nll.stderr
src/test/ui/in-band-lifetimes/impl/dyn-trait.nll.stderr
src/test/ui/issue-10291.nll.stderr
src/test/ui/issue-13033.stderr
src/test/ui/issue-16683.nll.stderr
src/test/ui/issue-17758.nll.stderr
src/test/ui/issue-40510-1.nll.stderr
src/test/ui/issue-40510-3.nll.stderr
src/test/ui/issue-52213.nll.stderr
src/test/ui/issue-52533-1.nll.stderr [new file with mode: 0644]
src/test/ui/issue-52533-1.rs [new file with mode: 0644]
src/test/ui/issue-52533-1.stderr [new file with mode: 0644]
src/test/ui/issue-52533.nll.stderr [new file with mode: 0644]
src/test/ui/issue-52533.rs [new file with mode: 0644]
src/test/ui/issue-52533.stderr [new file with mode: 0644]
src/test/ui/mismatched_types/E0053.stderr
src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr
src/test/ui/nll/closure-requirements/escape-argument-callee.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr
src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr
src/test/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr
src/test/ui/nll/closure-requirements/region-lbr-named-does-not-outlive-static.stderr
src/test/ui/nll/closure-requirements/return-wrong-bound-region.stderr
src/test/ui/nll/issue-50716.stderr
src/test/ui/nll/mir_check_cast_reify.stderr
src/test/ui/nll/mir_check_cast_unsafe_fn.stderr
src/tools/build-manifest/src/main.rs
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/read2.rs
src/tools/error_index_generator/main.rs
src/tools/remote-test-client/src/main.rs
src/tools/remote-test-server/src/main.rs
src/tools/tidy/src/features.rs
src/tools/tidy/src/lib.rs

index f2b2f6f1eebe1ebe6c86aae1c8b6f46f34fb11aa..7192cae8956e40b5157ac0ea5a34414f99e6d296 100644 (file)
@@ -296,8 +296,10 @@ fn main() {
         cmd.arg("--color=always");
     }
 
-    if env::var_os("RUSTC_DENY_WARNINGS").is_some() {
+    if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
+    {
         cmd.arg("-Dwarnings");
+        cmd.arg("-Dbare_trait_objects");
     }
 
     if verbose > 1 {
index 39c5c8328315a860617a46d04f93ed215dbac6fd..8838cdeed8687c1a488fc938a1eabdf47807844c 100644 (file)
@@ -12,7 +12,7 @@
 
 use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
 use builder::{RunConfig, Builder, ShouldRun, Step};
-use tool::{self, prepare_tool_cargo};
+use tool::{self, prepare_tool_cargo, SourceType};
 use {Compiler, Mode};
 use cache::{INTERNER, Interned};
 use std::path::PathBuf;
@@ -222,7 +222,8 @@ fn run(self, builder: &Builder) {
                                            Mode::ToolRustc,
                                            target,
                                            "check",
-                                           "src/tools/rustdoc");
+                                           "src/tools/rustdoc",
+                                           SourceType::InTree);
 
         let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
         println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
index f71cb119b77fea2dcb1be6b6ac819ed2503d3f33..fd3730ffc78de984c8063640c951812aba36fc2c 100644 (file)
@@ -28,7 +28,7 @@
 
 use util::symlink_dir;
 use builder::{Builder, Compiler, RunConfig, ShouldRun, Step};
-use tool::{self, prepare_tool_cargo, Tool};
+use tool::{self, prepare_tool_cargo, Tool, SourceType};
 use compile;
 use cache::{INTERNER, Interned};
 use config::Config;
@@ -814,6 +814,7 @@ fn run(self, builder: &Builder) {
             target,
             "doc",
             "src/tools/rustdoc",
+            SourceType::InTree,
         );
 
         cargo.env("RUSTDOCFLAGS", "--document-private-items");
index 639c96bc20810ce2f53b10630c2cf5710f7d6ea7..7c69197885cf2eaac1f2256809bc35bed9cd0594 100644 (file)
@@ -30,7 +30,7 @@
 use dist;
 use flags::Subcommand;
 use native;
-use tool::{self, Tool};
+use tool::{self, Tool, SourceType};
 use toolstate::ToolState;
 use util::{self, dylib_path, dylib_path_var};
 use Crate as CargoCrate;
@@ -222,17 +222,18 @@ fn run(self, builder: &Builder) {
             compiler,
             target: self.host,
         });
-        let mut cargo = builder.cargo(compiler, Mode::ToolRustc, self.host, "test");
-        cargo
-            .arg("--manifest-path")
-            .arg(builder.src.join("src/tools/cargo/Cargo.toml"));
+        let mut cargo = tool::prepare_tool_cargo(builder,
+                                                 compiler,
+                                                 Mode::ToolRustc,
+                                                 self.host,
+                                                 "test",
+                                                 "src/tools/cargo",
+                                                 SourceType::Submodule);
+
         if !builder.fail_fast {
             cargo.arg("--no-fail-fast");
         }
 
-        // Don't build tests dynamically, just a pain to work with
-        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
-
         // Don't run cross-compile tests, we may not have cross-compiled libstd libs
         // available.
         cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
@@ -286,10 +287,8 @@ fn run(self, builder: &Builder) {
                                                  Mode::ToolRustc,
                                                  host,
                                                  "test",
-                                                 "src/tools/rls");
-
-        // Don't build tests dynamically, just a pain to work with
-        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
+                                                 "src/tools/rls",
+                                                 SourceType::Submodule);
 
         builder.add_rustc_lib_path(compiler, &mut cargo);
 
@@ -341,10 +340,9 @@ fn run(self, builder: &Builder) {
                                                  Mode::ToolRustc,
                                                  host,
                                                  "test",
-                                                 "src/tools/rustfmt");
+                                                 "src/tools/rustfmt",
+                                                 SourceType::Submodule);
 
-        // Don't build tests dynamically, just a pain to work with
-        cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
         let dir = testdir(builder, compiler.host);
         t!(fs::create_dir_all(&dir));
         cargo.env("RUSTFMT_TEST_DIR", dir);
@@ -392,13 +390,14 @@ fn run(self, builder: &Builder) {
             extra_features: Vec::new(),
         });
         if let Some(miri) = miri {
-            let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
-            cargo
-                .arg("--manifest-path")
-                .arg(builder.src.join("src/tools/miri/Cargo.toml"));
+            let mut cargo = tool::prepare_tool_cargo(builder,
+                                                 compiler,
+                                                 Mode::ToolRustc,
+                                                 host,
+                                                 "test",
+                                                 "src/tools/miri",
+                                                 SourceType::Submodule);
 
-            // Don't build tests dynamically, just a pain to work with
-            cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
             // miri tests need to know about the stage sysroot
             cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
             cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
@@ -450,13 +449,14 @@ fn run(self, builder: &Builder) {
             extra_features: Vec::new(),
         });
         if let Some(clippy) = clippy {
-            let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test");
-            cargo
-                .arg("--manifest-path")
-                .arg(builder.src.join("src/tools/clippy/Cargo.toml"));
+            let mut cargo = tool::prepare_tool_cargo(builder,
+                                                 compiler,
+                                                 Mode::ToolRustc,
+                                                 host,
+                                                 "test",
+                                                 "src/tools/clippy",
+                                                 SourceType::Submodule);
 
-            // Don't build tests dynamically, just a pain to work with
-            cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
             // clippy tests need to know about the stage sysroot
             cargo.env("SYSROOT", builder.sysroot(compiler));
             cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
@@ -1739,7 +1739,8 @@ fn run(self, builder: &Builder) {
                                                  Mode::ToolRustc,
                                                  target,
                                                  test_kind.subcommand(),
-                                                 "src/tools/rustdoc");
+                                                 "src/tools/rustdoc",
+                                                 SourceType::InTree);
         if test_kind.subcommand() == "test" && !builder.fail_fast {
             cargo.arg("--no-fail-fast");
         }
index 0969e5abe07dcb52273ae0078e39a9f3c429944c..5e68b797b3d54fe4a80b7e8a5724e410e29e6a12 100644 (file)
@@ -75,6 +75,12 @@ fn run(self, builder: &Builder) {
     }
 }
 
+#[derive(Debug, Clone, Hash, PartialEq, Eq)]
+pub enum SourceType {
+    InTree,
+    Submodule,
+}
+
 #[derive(Debug, Clone, Hash, PartialEq, Eq)]
 struct ToolBuild {
     compiler: Compiler,
@@ -82,7 +88,8 @@ struct ToolBuild {
     tool: &'static str,
     path: &'static str,
     mode: Mode,
-    is_ext_tool: bool,
+    is_optional_tool: bool,
+    source_type: SourceType,
     extra_features: Vec<String>,
 }
 
@@ -102,7 +109,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
         let target = self.target;
         let tool = self.tool;
         let path = self.path;
-        let is_ext_tool = self.is_ext_tool;
+        let is_optional_tool = self.is_optional_tool;
 
         match self.mode {
             Mode::ToolRustc => {
@@ -115,7 +122,15 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
             _ => panic!("unexpected Mode for tool build")
         }
 
-        let mut cargo = prepare_tool_cargo(builder, compiler, self.mode, target, "build", path);
+        let mut cargo = prepare_tool_cargo(
+            builder,
+            compiler,
+            self.mode,
+            target,
+            "build",
+            path,
+            self.source_type,
+        );
         cargo.arg("--features").arg(self.extra_features.join(" "));
 
         let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
@@ -216,7 +231,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
         });
 
         if !is_expected {
-            if !is_ext_tool {
+            if !is_optional_tool {
                 exit(1);
             } else {
                 return None;
@@ -238,6 +253,7 @@ pub fn prepare_tool_cargo(
     target: Interned<String>,
     command: &'static str,
     path: &'static str,
+    source_type: SourceType,
 ) -> Command {
     let mut cargo = builder.cargo(compiler, mode, target, command);
     let dir = builder.src.join(path);
@@ -247,6 +263,10 @@ pub fn prepare_tool_cargo(
     // stages and such and it's just easier if they're not dynamically linked.
     cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
 
+    if source_type == SourceType::Submodule {
+        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);
@@ -274,7 +294,8 @@ pub fn prepare_tool_cargo(
 }
 
 macro_rules! tool {
-    ($($name:ident, $path:expr, $tool_name:expr, $mode:expr $(,llvm_tools = $llvm:expr)*;)+) => {
+    ($($name:ident, $path:expr, $tool_name:expr, $mode:expr
+        $(,llvm_tools = $llvm:expr)* $(,is_external_tool = $external:expr)*;)+) => {
         #[derive(Copy, PartialEq, Eq, Clone)]
         pub enum Tool {
             $(
@@ -351,7 +372,12 @@ fn run(self, builder: &Builder) -> PathBuf {
                     tool: $tool_name,
                     mode: $mode,
                     path: $path,
-                    is_ext_tool: false,
+                    is_optional_tool: false,
+                    source_type: if false $(|| $external)* {
+                        SourceType::Submodule
+                    } else {
+                        SourceType::InTree
+                    },
                     extra_features: Vec::new(),
                 }).expect("expected to build -- essential tool")
             }
@@ -370,7 +396,8 @@ fn run(self, builder: &Builder) -> PathBuf {
     Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
     BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
     RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::ToolBootstrap;
-    RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap;
+    RustInstaller, "src/tools/rust-installer", "fabricate", Mode::ToolBootstrap,
+        is_external_tool = true;
     RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
 );
 
@@ -401,7 +428,8 @@ fn run(self, builder: &Builder) -> PathBuf {
             tool: "remote-test-server",
             mode: Mode::ToolStd,
             path: "src/tools/remote-test-server",
-            is_ext_tool: false,
+            is_optional_tool: false,
+            source_type: SourceType::InTree,
             extra_features: Vec::new(),
         }).expect("expected to build -- essential tool")
     }
@@ -449,12 +477,15 @@ fn run(self, builder: &Builder) -> PathBuf {
             target: builder.config.build,
         });
 
-        let mut cargo = prepare_tool_cargo(builder,
-                                           build_compiler,
-                                           Mode::ToolRustc,
-                                           target,
-                                           "build",
-                                           "src/tools/rustdoc");
+        let mut cargo = prepare_tool_cargo(
+            builder,
+            build_compiler,
+            Mode::ToolRustc,
+            target,
+            "build",
+            "src/tools/rustdoc",
+            SourceType::InTree,
+        );
 
         // Most tools don't get debuginfo, but rustdoc should.
         cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
@@ -525,7 +556,8 @@ fn run(self, builder: &Builder) -> PathBuf {
             tool: "cargo",
             mode: Mode::ToolRustc,
             path: "src/tools/cargo",
-            is_ext_tool: false,
+            is_optional_tool: false,
+            source_type: SourceType::Submodule,
             extra_features: Vec::new(),
         }).expect("expected to build -- essential tool")
     }
@@ -574,7 +606,8 @@ fn run(mut $sel, $builder: &Builder) -> Option<PathBuf> {
                     mode: Mode::ToolRustc,
                     path: $path,
                     extra_features: $sel.extra_features,
-                    is_ext_tool: true,
+                    is_optional_tool: true,
+                    source_type: SourceType::Submodule,
                 })
             }
         }
index 00e5dee256eebc4c2d4f993b6a60500434941cb1..1cbb8e49bfa15e0579ebeb0e3b37aa0d0bda10db 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 use std::fs::File;
 use std::path::{Path, PathBuf};
 use std::process::{Command, Stdio};
index e8d6c12de4474284c529a8852863c81eb9ff317f..7adb32efa1d414ef8daa1f1030fd7d92bcd51f24 100644 (file)
@@ -34,12 +34,12 @@ COPY scripts/sccache.sh /scripts/
 RUN sh /scripts/sccache.sh
 
 ENV \
-    AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \
-    CC_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang \
-    CXX_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang++ \
-    AR_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-ar \
-    CC_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang \
-    CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++ \
+    AR_x86_64_fuchsia=x86_64-fuchsia-ar \
+    CC_x86_64_fuchsia=x86_64-fuchsia-clang \
+    CXX_x86_64_fuchsia=x86_64-fuchsia-clang++ \
+    AR_aarch64_fuchsia=aarch64-fuchsia-ar \
+    CC_aarch64_fuchsia=aarch64-fuchsia-clang \
+    CXX_aarch64_fuchsia=aarch64-fuchsia-clang++ \
     AR_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-ar \
     CC_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-gcc \
     CXX_sparcv9_sun_solaris=sparcv9-sun-solaris2.10-g++ \
@@ -47,8 +47,8 @@ ENV \
     CC_x86_64_sun_solaris=x86_64-sun-solaris2.10-gcc \
     CXX_x86_64_sun_solaris=x86_64-sun-solaris2.10-g++
 
-ENV TARGETS=x86_64-unknown-fuchsia
-ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia
+ENV TARGETS=x86_64-fuchsia
+ENV TARGETS=$TARGETS,aarch64-fuchsia
 ENV TARGETS=$TARGETS,sparcv9-sun-solaris
 ENV TARGETS=$TARGETS,wasm32-unknown-unknown
 ENV TARGETS=$TARGETS,x86_64-sun-solaris
index ef8f0c37f8c370073c277c984203524ccab5db24..ec19f7c4f45d972aaa5dac84c5f11da455ad7c17 100755 (executable)
@@ -39,7 +39,7 @@ build() {
   esac
 
   hide_output make -j$(getconf _NPROCESSORS_ONLN) $tgt
-  dst=/usr/local/${arch}-unknown-fuchsia
+  dst=/usr/local/${arch}-fuchsia
   mkdir -p $dst
   cp -a build-${tgt}/sysroot/include $dst/
   cp -a build-${tgt}/sysroot/lib $dst/
@@ -55,11 +55,11 @@ rm -rf zircon
 
 for arch in x86_64 aarch64; do
   for tool in clang clang++; do
-    cat >/usr/local/bin/${arch}-unknown-fuchsia-${tool} <<EOF
+    cat >/usr/local/bin/${arch}-fuchsia-${tool} <<EOF
 #!/bin/sh
-${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@"
+${tool} --target=${arch}-fuchsia --sysroot=/usr/local/${arch}-fuchsia "\$@"
 EOF
-    chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool}
+    chmod +x /usr/local/bin/${arch}-fuchsia-${tool}
   done
-  ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar
+  ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-fuchsia-ar
 done
index 63cf01a0facbca245ebc2b393464df9fdf85898b..ef619527e064a34d2f8f387881619570393cde5d 100644 (file)
@@ -72,7 +72,6 @@
        test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
 #![no_std]
 #![needs_allocator]
-#![deny(bare_trait_objects)]
 #![deny(missing_debug_implementations)]
 
 #![cfg_attr(test, allow(deprecated))] // rand
index 753873dd294ce19564c075a6bf275706e4ba5553..d90c22a3b18924496c9967a8e699ac6bc69684fc 100644 (file)
@@ -18,7 +18,7 @@ enum Void {}
     a = a.clone();
     assert!(a.upgrade().is_none());
 
-    let mut a: Weak<Any> = a;  // Unsizing
+    let mut a: Weak<dyn Any> = a;  // Unsizing
     a = a.clone();
     assert!(a.upgrade().is_none());
 }
@@ -39,7 +39,7 @@ fn slice() {
 #[test]
 fn trait_object() {
     let a: Arc<u32> = Arc::new(4);
-    let a: Arc<Any> = a;  // Unsizing
+    let a: Arc<dyn Any> = a;  // Unsizing
 
     // Exercise is_dangling() with a DST
     let mut a = Arc::downgrade(&a);
@@ -49,7 +49,7 @@ fn trait_object() {
     let mut b = Weak::<u32>::new();
     b = b.clone();
     assert!(b.upgrade().is_none());
-    let mut b: Weak<Any> = b;  // Unsizing
+    let mut b: Weak<dyn Any> = b;  // Unsizing
     b = b.clone();
     assert!(b.upgrade().is_none());
 }
index 6171b8ba624cd5581b505d3eb47cfc43d8e81c7c..0330bda5e3238527c16071d92ebe585888e80311 100644 (file)
@@ -40,7 +40,7 @@ fn test_hash() {
 }
 
 fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
-    where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut FnMut(&i32) -> bool) -> bool
+    where F: FnOnce(&BTreeSet<i32>, &BTreeSet<i32>, &mut dyn FnMut(&i32) -> bool) -> bool
 {
     let mut set_a = BTreeSet::new();
     let mut set_b = BTreeSet::new();
index d3cbad0284b464068decd8599b5c5df437347a2a..618aff963f22dd59bc8d549bd4fc585ecd4d8847 100644 (file)
@@ -64,7 +64,7 @@ fn test_boxed_hasher() {
     5u32.hash(&mut hasher_1);
     assert_eq!(ordinary_hash, hasher_1.finish());
 
-    let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<Hasher>;
+    let mut hasher_2 = Box::new(DefaultHasher::new()) as Box<dyn Hasher>;
     5u32.hash(&mut hasher_2);
     assert_eq!(ordinary_hash, hasher_2.finish());
 }
index baa0406acfc3dbcc02cdc8d1f2f2d349cd225349..9ec7c831444d18d02881e2b11a103da0332cc930 100644 (file)
@@ -18,7 +18,7 @@ enum Void {}
     a = a.clone();
     assert!(a.upgrade().is_none());
 
-    let mut a: Weak<Any> = a;  // Unsizing
+    let mut a: Weak<dyn Any> = a;  // Unsizing
     a = a.clone();
     assert!(a.upgrade().is_none());
 }
@@ -39,7 +39,7 @@ fn slice() {
 #[test]
 fn trait_object() {
     let a: Rc<u32> = Rc::new(4);
-    let a: Rc<Any> = a;  // Unsizing
+    let a: Rc<dyn Any> = a;  // Unsizing
 
     // Exercise is_dangling() with a DST
     let mut a = Rc::downgrade(&a);
@@ -49,7 +49,7 @@ fn trait_object() {
     let mut b = Weak::<u32>::new();
     b = b.clone();
     assert!(b.upgrade().is_none());
-    let mut b: Weak<Any> = b;  // Unsizing
+    let mut b: Weak<dyn Any> = b;  // Unsizing
     b = b.clone();
     assert!(b.upgrade().is_none());
 }
index 413b212281b74336383addbec46d46404f0b0038..b3b20715511a7627662d6eac5550f62f6db4508e 100644 (file)
@@ -10,7 +10,6 @@
 
 #![no_std]
 #![allow(unused_attributes)]
-#![deny(bare_trait_objects)]
 #![unstable(feature = "alloc_jemalloc",
             reason = "implementation detail of std, does not provide any public API",
             issue = "0")]
index c6c0abefbab23c6e42de21da4deb861a89978485..64348e05de7db16967708aded5d286e613cd75b1 100644 (file)
@@ -10,7 +10,6 @@
 
 #![no_std]
 #![allow(unused_attributes)]
-#![deny(bare_trait_objects)]
 #![unstable(feature = "alloc_system",
             reason = "this library is unlikely to be stabilized in its current \
                       form or name",
index 6f692923c8534c6f367735ef722bcd02228b1d92..0f4a5d16e1759aa1a4a0f957930fc5b02235c757 100644 (file)
@@ -30,7 +30,6 @@
 #![cfg_attr(test, feature(test))]
 
 #![allow(deprecated)]
-#![deny(bare_trait_objects)]
 
 extern crate alloc;
 extern crate rustc_data_structures;
index 94f23db1ccc36b4e6123d1aaa9145b7812a82fcd..6b26093439e4f509925d0be5eff19329f554b6b8 100644 (file)
@@ -120,7 +120,7 @@ fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
 ///////////////////////////////////////////////////////////////////////////////
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl fmt::Debug for Any {
+impl fmt::Debug for dyn Any {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.pad("Any")
     }
@@ -130,20 +130,20 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 // hence used with `unwrap`. May eventually no longer be needed if
 // dispatch works with upcasting.
 #[stable(feature = "rust1", since = "1.0.0")]
-impl fmt::Debug for Any + Send {
+impl fmt::Debug for dyn Any + Send {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.pad("Any")
     }
 }
 
 #[stable(feature = "any_send_sync_methods", since = "1.28.0")]
-impl fmt::Debug for Any + Send + Sync {
+impl fmt::Debug for dyn Any + Send + Sync {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.pad("Any")
     }
 }
 
-impl Any {
+impl dyn Any {
     /// Returns `true` if the boxed type is the same as `T`.
     ///
     /// # Examples
@@ -203,7 +203,7 @@ pub fn is<T: Any>(&self) -> bool {
     pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
         if self.is::<T>() {
             unsafe {
-                Some(&*(self as *const Any as *const T))
+                Some(&*(self as *const dyn Any as *const T))
             }
         } else {
             None
@@ -240,7 +240,7 @@ pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
     pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
         if self.is::<T>() {
             unsafe {
-                Some(&mut *(self as *mut Any as *mut T))
+                Some(&mut *(self as *mut dyn Any as *mut T))
             }
         } else {
             None
@@ -248,7 +248,7 @@ pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
     }
 }
 
-impl Any+Send {
+impl dyn Any+Send {
     /// Forwards to the method defined on the type `Any`.
     ///
     /// # Examples
@@ -332,7 +332,7 @@ pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
     }
 }
 
-impl Any+Send+Sync {
+impl dyn Any+Send+Sync {
     /// Forwards to the method defined on the type `Any`.
     ///
     /// # Examples
index b6087628ea6a487ac9ccf7641335bc070a8c5274..137e9fe2c1533e251a09e54c6c0a86879c7d4332 100644 (file)
@@ -1532,7 +1532,7 @@ impl<T: CoerceUnsized<U>, U> CoerceUnsized<UnsafeCell<U>> for UnsafeCell<T> {}
 
 #[allow(unused)]
 fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) {
-    let _: UnsafeCell<&Send> = a;
-    let _: Cell<&Send> = b;
-    let _: RefCell<&Send> = c;
+    let _: UnsafeCell<&dyn Send> = a;
+    let _: Cell<&dyn Send> = b;
+    let _: RefCell<&dyn Send> = c;
 }
index e8ea2e743da93c92cf645b0d23c1723129498b5c..3c5f934d4d8c795ce9b5842a18b62032422c961f 100644 (file)
@@ -11,7 +11,7 @@
 use fmt;
 
 struct PadAdapter<'a> {
-    buf: &'a mut (fmt::Write + 'a),
+    buf: &'a mut (dyn fmt::Write + 'a),
     on_newline: bool,
 }
 
@@ -107,7 +107,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>,
 impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
     /// Adds a new field to the generated struct output.
     #[stable(feature = "debug_builders", since = "1.2.0")]
-    pub fn field(&mut self, name: &str, value: &fmt::Debug) -> &mut DebugStruct<'a, 'b> {
+    pub fn field(&mut self, name: &str, value: &dyn fmt::Debug) -> &mut DebugStruct<'a, 'b> {
         self.result = self.result.and_then(|_| {
             let prefix = if self.has_fields {
                 ","
@@ -204,7 +204,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D
 impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
     /// Adds a new field to the generated tuple struct output.
     #[stable(feature = "debug_builders", since = "1.2.0")]
-    pub fn field(&mut self, value: &fmt::Debug) -> &mut DebugTuple<'a, 'b> {
+    pub fn field(&mut self, value: &dyn fmt::Debug) -> &mut DebugTuple<'a, 'b> {
         self.result = self.result.and_then(|_| {
             let (prefix, space) = if self.fields > 0 {
                 (",", " ")
@@ -258,7 +258,7 @@ struct DebugInner<'a, 'b: 'a> {
 }
 
 impl<'a, 'b: 'a> DebugInner<'a, 'b> {
-    fn entry(&mut self, entry: &fmt::Debug) {
+    fn entry(&mut self, entry: &dyn fmt::Debug) {
         self.result = self.result.and_then(|_| {
             if self.is_pretty() {
                 let mut slot = None;
@@ -340,7 +340,7 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b
 impl<'a, 'b: 'a> DebugSet<'a, 'b> {
     /// Adds a new entry to the set output.
     #[stable(feature = "debug_builders", since = "1.2.0")]
-    pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugSet<'a, 'b> {
+    pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugSet<'a, 'b> {
         self.inner.entry(entry);
         self
     }
@@ -411,7 +411,7 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,
 impl<'a, 'b: 'a> DebugList<'a, 'b> {
     /// Adds a new entry to the list output.
     #[stable(feature = "debug_builders", since = "1.2.0")]
-    pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugList<'a, 'b> {
+    pub fn entry(&mut self, entry: &dyn fmt::Debug) -> &mut DebugList<'a, 'b> {
         self.inner.entry(entry);
         self
     }
@@ -482,7 +482,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b
 impl<'a, 'b: 'a> DebugMap<'a, 'b> {
     /// Adds a new entry to the map output.
     #[stable(feature = "debug_builders", since = "1.2.0")]
-    pub fn entry(&mut self, key: &fmt::Debug, value: &fmt::Debug) -> &mut DebugMap<'a, 'b> {
+    pub fn entry(&mut self, key: &dyn fmt::Debug, value: &dyn fmt::Debug) -> &mut DebugMap<'a, 'b> {
         self.result = self.result.and_then(|_| {
             if self.is_pretty() {
                 let mut slot = None;
index d91bf4633833716da7c7d89c653e52bc67f26698..928f95e3ba2ea2a65c7cc2fa1aab225d2588dbec 100644 (file)
@@ -255,7 +255,7 @@ pub struct Formatter<'a> {
     width: Option<usize>,
     precision: Option<usize>,
 
-    buf: &'a mut (Write+'a),
+    buf: &'a mut (dyn Write+'a),
     curarg: slice::Iter<'a, ArgumentV1<'a>>,
     args: &'a [ArgumentV1<'a>],
 }
@@ -272,7 +272,7 @@ struct Void {
     ///
     /// It was added after #45197 showed that one could share a `!Sync`
     /// object across threads by passing it into `format_args!`.
-    _oibit_remover: PhantomData<*mut Fn()>,
+    _oibit_remover: PhantomData<*mut dyn Fn()>,
 }
 
 /// This struct represents the generic "argument" which is taken by the Xprintf
@@ -1020,7 +1020,7 @@ pub trait UpperExp {
 ///
 /// [`write!`]: ../../std/macro.write.html
 #[stable(feature = "rust1", since = "1.0.0")]
-pub fn write(output: &mut Write, args: Arguments) -> Result {
+pub fn write(output: &mut dyn Write, args: Arguments) -> Result {
     let mut formatter = Formatter {
         flags: 0,
         width: None,
@@ -1062,7 +1062,7 @@ pub fn write(output: &mut Write, args: Arguments) -> Result {
 
 impl<'a> Formatter<'a> {
     fn wrap_buf<'b, 'c, F>(&'b mut self, wrap: F) -> Formatter<'c>
-        where 'b: 'c, F: FnOnce(&'b mut (Write+'b)) -> &'c mut (Write+'c)
+        where 'b: 'c, F: FnOnce(&'b mut (dyn Write+'b)) -> &'c mut (dyn Write+'c)
     {
         Formatter {
             // We want to change this
@@ -1342,7 +1342,7 @@ fn pad_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result {
     }
 
     fn write_formatted_parts(&mut self, formatted: &flt2dec::Formatted) -> Result {
-        fn write_bytes(buf: &mut Write, s: &[u8]) -> Result {
+        fn write_bytes(buf: &mut dyn Write, s: &[u8]) -> Result {
             buf.write_str(unsafe { str::from_utf8_unchecked(s) })
         }
 
index afc273d265b9c0e89748a2de3ce534b21d75d8ec..48c6eb94144296ec7c4785171ec7223337b638b7 100644 (file)
@@ -18,7 +18,7 @@
 use super::{Zip, Sum, Product};
 use super::{ChainState, FromIterator, ZipImpl};
 
-fn _assert_is_object_safe(_: &Iterator<Item=()>) {}
+fn _assert_is_object_safe(_: &dyn Iterator<Item=()>) {}
 
 /// An interface for dealing with iterators.
 ///
index 10f02ca2fdc45cf8e06b291fa94070370729109a..17cac5aa0a05fd1e5a4eed9ca078f29c9a6533dd 100644 (file)
@@ -43,7 +43,7 @@
 #[stable(feature = "panic_hooks", since = "1.10.0")]
 #[derive(Debug)]
 pub struct PanicInfo<'a> {
-    payload: &'a (Any + Send),
+    payload: &'a (dyn Any + Send),
     message: Option<&'a fmt::Arguments<'a>>,
     location: Location<'a>,
 }
@@ -64,7 +64,7 @@ pub fn internal_constructor(message: Option<&'a fmt::Arguments<'a>>,
 
     #[doc(hidden)]
     #[inline]
-    pub fn set_payload(&mut self, info: &'a (Any + Send)) {
+    pub fn set_payload(&mut self, info: &'a (dyn Any + Send)) {
         self.payload = info;
     }
 
@@ -86,7 +86,7 @@ pub fn set_payload(&mut self, info: &'a (Any + Send)) {
     /// panic!("Normal panic");
     /// ```
     #[stable(feature = "panic_hooks", since = "1.10.0")]
-    pub fn payload(&self) -> &(Any + Send) {
+    pub fn payload(&self) -> &(dyn Any + Send) {
         self.payload
     }
 
@@ -270,6 +270,6 @@ fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
 #[unstable(feature = "std_internals", issue = "0")]
 #[doc(hidden)]
 pub unsafe trait BoxMeUp {
-    fn box_me_up(&mut self) -> *mut (Any + Send);
-    fn get(&mut self) -> &(Any + Send);
+    fn box_me_up(&mut self) -> *mut (dyn Any + Send);
+    fn get(&mut self) -> &(dyn Any + Send);
 }
index c69d45248a597c09ea434208292f5ec40a23900d..1fc975cb178819d9584c8c3604ea36fab5b93a08 100644 (file)
@@ -21,7 +21,7 @@
 /// when performing a single `poll` step on a task.
 pub struct Context<'a> {
     local_waker: &'a LocalWaker,
-    executor: &'a mut Executor,
+    executor: &'a mut dyn Executor,
 }
 
 impl<'a> fmt::Debug for Context<'a> {
@@ -34,7 +34,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 impl<'a> Context<'a> {
     /// Create a new task `Context` with the provided `local_waker`, `waker`, and `executor`.
     #[inline]
-    pub fn new(local_waker: &'a LocalWaker, executor: &'a mut Executor) -> Context<'a> {
+    pub fn new(local_waker: &'a LocalWaker, executor: &'a mut dyn Executor) -> Context<'a> {
         Context {
             local_waker,
             executor,
@@ -58,7 +58,7 @@ pub fn waker(&self) -> &'a Waker {
     /// This method is useful primarily if you want to explicitly handle
     /// spawn failures.
     #[inline]
-    pub fn executor(&mut self) -> &mut Executor {
+    pub fn executor(&mut self) -> &mut dyn Executor {
         self.executor
     }
 
index 3b901c9aef0ca95bb5c09a6479c813b993da8083..321b432d3f4307b7c29681caddda75b5453bf2c3 100644 (file)
@@ -23,7 +23,7 @@
 /// trait, allowing notifications to get routed through it.
 #[repr(transparent)]
 pub struct Waker {
-    inner: NonNull<UnsafeWake>,
+    inner: NonNull<dyn UnsafeWake>,
 }
 
 impl Unpin for Waker {}
@@ -41,7 +41,7 @@ impl Waker {
     /// use the `Waker::from` function instead which works with the safe
     /// `Arc` type and the safe `Wake` trait.
     #[inline]
-    pub unsafe fn new(inner: NonNull<UnsafeWake>) -> Self {
+    pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
         Waker { inner: inner }
     }
 
@@ -98,7 +98,7 @@ fn drop(&mut self) {
 /// behavior.
 #[repr(transparent)]
 pub struct LocalWaker {
-    inner: NonNull<UnsafeWake>,
+    inner: NonNull<dyn UnsafeWake>,
 }
 
 impl Unpin for LocalWaker {}
@@ -119,7 +119,7 @@ impl LocalWaker {
     /// For this function to be used safely, it must be sound to call `inner.wake_local()`
     /// on the current thread.
     #[inline]
-    pub unsafe fn new(inner: NonNull<UnsafeWake>) -> Self {
+    pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
         LocalWaker { inner: inner }
     }
 
index 2d3e81aa131ed4ceb5fc7d2696af966b9d9c660b..a80bf93953039fe91afeee3f4d451ef23314ca2a 100644 (file)
@@ -17,7 +17,7 @@
 
 #[test]
 fn any_referenced() {
-    let (a, b, c) = (&5 as &Any, &TEST as &Any, &Test as &Any);
+    let (a, b, c) = (&5 as &dyn Any, &TEST as &dyn Any, &Test as &dyn Any);
 
     assert!(a.is::<i32>());
     assert!(!b.is::<i32>());
@@ -34,7 +34,11 @@ fn any_referenced() {
 
 #[test]
 fn any_owning() {
-    let (a, b, c) = (box 5_usize as Box<Any>, box TEST as Box<Any>, box Test as Box<Any>);
+    let (a, b, c) = (
+        box 5_usize as Box<dyn Any>,
+        box TEST as Box<dyn Any>,
+        box Test as Box<dyn Any>,
+    );
 
     assert!(a.is::<usize>());
     assert!(!b.is::<usize>());
@@ -51,7 +55,7 @@ fn any_owning() {
 
 #[test]
 fn any_downcast_ref() {
-    let a = &5_usize as &Any;
+    let a = &5_usize as &dyn Any;
 
     match a.downcast_ref::<usize>() {
         Some(&5) => {}
@@ -69,9 +73,9 @@ fn any_downcast_mut() {
     let mut a = 5_usize;
     let mut b: Box<_> = box 7_usize;
 
-    let a_r = &mut a as &mut Any;
+    let a_r = &mut a as &mut dyn Any;
     let tmp: &mut usize = &mut *b;
-    let b_r = tmp as &mut Any;
+    let b_r = tmp as &mut dyn Any;
 
     match a_r.downcast_mut::<usize>() {
         Some(x) => {
@@ -113,7 +117,7 @@ fn any_downcast_mut() {
 #[test]
 fn any_fixed_vec() {
     let test = [0_usize; 8];
-    let test = &test as &Any;
+    let test = &test as &dyn Any;
     assert!(test.is::<[usize; 8]>());
     assert!(!test.is::<[usize; 10]>());
 }
index 8716421b424deb3106639ead19edc26954838fd3..85c9d41b65b591d255ccc2666fb3c352c4bce548 100644 (file)
@@ -128,7 +128,7 @@ fn hash<T: Hash>(t: &T) -> u64 {
 fn test_indirect_hasher() {
     let mut hasher = MyHasher { hash: 0 };
     {
-        let mut indirect_hasher: &mut Hasher = &mut hasher;
+        let mut indirect_hasher: &mut dyn Hasher = &mut hasher;
         5u32.hash(&mut indirect_hasher);
     }
     assert_eq!(hasher.hash, 5);
index 2b380abf63c58dddab364dcb64be682279d9df87..9f3cba26a62db894e11bf72ae7204dda47fe4a65 100644 (file)
@@ -22,7 +22,7 @@ fn test_typeid_sized_types() {
 #[test]
 fn test_typeid_unsized_types() {
     trait Z {}
-    struct X(str); struct Y(Z + 'static);
+    struct X(str); struct Y(dyn Z + 'static);
 
     assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
     assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
index f55a1c81463f77ab0a8a6dd7c1946ae3c0c33a4a..714f2babbdff685ff73af76cb22f4a6a8dbab795 100644 (file)
@@ -109,11 +109,11 @@ fn test_transmute() {
     trait Foo { fn dummy(&self) { } }
     impl Foo for isize {}
 
-    let a = box 100isize as Box<Foo>;
+    let a = box 100isize as Box<dyn Foo>;
     unsafe {
         let x: ::core::raw::TraitObject = transmute(a);
         assert!(*(x.data as *const isize) == 100);
-        let _x: Box<Foo> = transmute(x);
+        let _x: Box<dyn Foo> = transmute(x);
     }
 
     unsafe {
index bc3e61a4f541f71f86d62aaee68119b9888d7102..324ebf435651d79e2145de8aa1a369b6b4e0a0e4 100644 (file)
@@ -240,7 +240,7 @@ fn test_collect() {
     assert!(v == None);
 
     // test that it does not take more elements than it needs
-    let mut functions: [Box<Fn() -> Option<()>>; 3] =
+    let mut functions: [Box<dyn Fn() -> Option<()>>; 3] =
         [box || Some(()), box || None, box || panic!()];
 
     let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect();
index 31bc1d677686a59c8ee11ffc92882dc0cb80d9e5..92160910d8f705ab3e0908851ad455147776a82e 100644 (file)
@@ -84,16 +84,16 @@ fn test_is_null() {
     assert!(nms.is_null());
 
     // Pointers to unsized types -- trait objects
-    let ci: *const ToString = &3;
+    let ci: *const dyn ToString = &3;
     assert!(!ci.is_null());
 
-    let mi: *mut ToString = &mut 3;
+    let mi: *mut dyn ToString = &mut 3;
     assert!(!mi.is_null());
 
-    let nci: *const ToString = null::<isize>();
+    let nci: *const dyn ToString = null::<isize>();
     assert!(nci.is_null());
 
-    let nmi: *mut ToString = null_mut::<isize>();
+    let nmi: *mut dyn ToString = null_mut::<isize>();
     assert!(nmi.is_null());
 }
 
@@ -140,16 +140,16 @@ fn test_as_ref() {
         assert_eq!(nms.as_ref(), None);
 
         // Pointers to unsized types -- trait objects
-        let ci: *const ToString = &3;
+        let ci: *const dyn ToString = &3;
         assert!(ci.as_ref().is_some());
 
-        let mi: *mut ToString = &mut 3;
+        let mi: *mut dyn ToString = &mut 3;
         assert!(mi.as_ref().is_some());
 
-        let nci: *const ToString = null::<isize>();
+        let nci: *const dyn ToString = null::<isize>();
         assert!(nci.as_ref().is_none());
 
-        let nmi: *mut ToString = null_mut::<isize>();
+        let nmi: *mut dyn ToString = null_mut::<isize>();
         assert!(nmi.as_ref().is_none());
     }
 }
@@ -182,10 +182,10 @@ fn test_as_mut() {
         assert_eq!(nms.as_mut(), None);
 
         // Pointers to unsized types -- trait objects
-        let mi: *mut ToString = &mut 3;
+        let mi: *mut dyn ToString = &mut 3;
         assert!(mi.as_mut().is_some());
 
-        let nmi: *mut ToString = null_mut::<isize>();
+        let nmi: *mut dyn ToString = null_mut::<isize>();
         assert!(nmi.as_mut().is_none());
     }
 }
index d9927ce4487e95492714ebf6ae274c929f637dab..0616252c82c89cf35d26e4a6e46f4eb4835ef458 100644 (file)
@@ -81,7 +81,7 @@ fn test_collect() {
     assert!(v == Err(2));
 
     // test that it does not take more elements than it needs
-    let mut functions: [Box<Fn() -> Result<(), isize>>; 3] =
+    let mut functions: [Box<dyn Fn() -> Result<(), isize>>; 3] =
         [box || Ok(()), box || Err(1), box || panic!()];
 
     let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect();
index 30a3bbdc58e988b4c85326c774f318aa1428b39e..3aa09a91e076595178880c623878197b647823c5 100644 (file)
@@ -14,8 +14,6 @@
 //! Parsing does not happen at runtime: structures of `std::fmt::rt` are
 //! generated instead.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/",
index 9e71ed4063e87e3d2eb56969a4b3303f2b8357d7..158d0101515860af76c7562e987267a7818a2102 100644 (file)
 //!
 //! * [DOT language](http://www.graphviz.org/doc/info/lang.html)
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/",
index 02ab28507d7d86d13eb73fac44c3aa15a2f64889..392bf17968fbdfc28f648b7b9f94f2c5d16e403f 100644 (file)
@@ -21,7 +21,6 @@
        issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
 #![panic_runtime]
 #![allow(unused_features)]
-#![deny(bare_trait_objects)]
 
 #![feature(core_intrinsics)]
 #![feature(libc)]
index f8cd29fc0861fe4d7a43b8fe646a6bb2d5322166..5c320bb369e709b63024f43b7f00bf846abf29e4 100644 (file)
@@ -22,7 +22,6 @@
 //! More documentation about each implementation can be found in the respective
 //! module.
 
-#![deny(bare_trait_objects)]
 #![no_std]
 #![unstable(feature = "panic_unwind", issue = "32837")]
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
index 61da9db76f6c81e4ca4346b6e61d5025a8ba03b1..bf6e4a3aaa40585cf8b668908b449ae94ca56a65 100644 (file)
@@ -22,7 +22,6 @@
 //! See [the book](../book/first-edition/procedural-macros.html) for more.
 
 #![stable(feature = "proc_macro_lib", since = "1.15.0")]
-#![deny(bare_trait_objects)]
 #![deny(missing_docs)]
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
index 3d91505cd772aae53c2b1fa9b12132bbcd0260cf..6d0d6d115b7163528e3e0a54737ce114124ffe32 100644 (file)
@@ -15,5 +15,4 @@
             reason = "internal implementation detail of rustc right now",
             issue = "0")]
 #![allow(unused_features)]
-#![deny(bare_trait_objects)]
 #![feature(staged_api)]
index 656f325b4dd89e4fc5616b55869fe74425869f65..a17c160c4d03e5340051d6597dd69ab1a7ed59cf 100644 (file)
@@ -105,7 +105,7 @@ fn check<F: FnOnce(&mut HirIdValidator<'a, 'hir>)>(&mut self,
               .collect();
 
             // Try to map those to something more useful
-            let mut missing_items = vec![];
+            let mut missing_items = Vec::with_capacity(missing.len());
 
             for local_id in missing {
                 let hir_id = HirId {
index ae4d88704a098e830c10bc3faafd19b5c1095f5d..205f8c5ad068caee0ab33b171f14b2aa715f0762 100644 (file)
@@ -691,25 +691,41 @@ fn instantiate_anon_types_in_map<T: TypeFoldable<'tcx>>(&mut self, value: &T) ->
                     // }
                     // ```
                     if let Some(anon_node_id) = tcx.hir.as_local_node_id(def_id) {
-                        let in_definition_scope = match tcx.hir.expect_item(anon_node_id).node {
-                            // impl trait
-                            hir::ItemKind::Existential(hir::ExistTy {
-                                impl_trait_fn: Some(parent),
-                                ..
-                            }) => parent == self.parent_def_id,
-                            // named existential types
-                            hir::ItemKind::Existential(hir::ExistTy {
-                                impl_trait_fn: None,
-                                ..
-                            }) => may_define_existential_type(
-                                tcx,
-                                self.parent_def_id,
-                                anon_node_id,
-                            ),
-                            _ => {
-                                let anon_parent_node_id = tcx.hir.get_parent(anon_node_id);
-                                self.parent_def_id == tcx.hir.local_def_id(anon_parent_node_id)
+                        let parent_def_id = self.parent_def_id;
+                        let def_scope_default = || {
+                            let anon_parent_node_id = tcx.hir.get_parent(anon_node_id);
+                            parent_def_id == tcx.hir.local_def_id(anon_parent_node_id)
+                        };
+                        let in_definition_scope = match tcx.hir.find(anon_node_id) {
+                            Some(hir::map::NodeItem(item)) => match item.node {
+                                // impl trait
+                                hir::ItemKind::Existential(hir::ExistTy {
+                                    impl_trait_fn: Some(parent),
+                                    ..
+                                }) => parent == self.parent_def_id,
+                                // named existential types
+                                hir::ItemKind::Existential(hir::ExistTy {
+                                    impl_trait_fn: None,
+                                    ..
+                                }) => may_define_existential_type(
+                                    tcx,
+                                    self.parent_def_id,
+                                    anon_node_id,
+                                ),
+                                _ => def_scope_default(),
                             },
+                            Some(hir::map::NodeImplItem(item)) => match item.node {
+                                hir::ImplItemKind::Existential(_) => may_define_existential_type(
+                                    tcx,
+                                    self.parent_def_id,
+                                    anon_node_id,
+                                ),
+                                _ => def_scope_default(),
+                            },
+                            _ => bug!(
+                                "expected (impl) item, found {}",
+                                tcx.hir.node_to_string(anon_node_id),
+                            ),
                         };
                         if in_definition_scope {
                             return self.fold_anon_ty(ty, def_id, substs);
index dbcb63addb846f3ee68ebc05add77f631357dddb..693219ec4b03f518e4d2c39429364f95bc8e2bff 100644 (file)
@@ -74,7 +74,7 @@ fn visit_body(&mut self, body: &'gcx Body) {
 
 
 impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
-    fn extract_type_name(&self, ty: &'a Ty<'tcx>) -> String {
+    pub fn extract_type_name(&self, ty: &'a Ty<'tcx>) -> String {
         if let ty::TyInfer(ty::TyVar(ty_vid)) = (*ty).sty {
             let ty_vars = self.type_variables.borrow();
             if let TypeVariableOrigin::TypeParameterDefinition(_, name) =
index 07286f1250cd38f4063dce51754e7b205a96aee9..b8991a0366a61d0672e3ff214bcfa682a8b24b72 100644 (file)
@@ -505,11 +505,7 @@ fn projection_bound(
     }
 
     fn recursive_type_bound(&self, ty: Ty<'tcx>) -> VerifyBound<'tcx> {
-        let mut bounds = vec![];
-
-        for subty in ty.walk_shallow() {
-            bounds.push(self.type_bound(subty));
-        }
+        let mut bounds = ty.walk_shallow().map(|subty| self.type_bound(subty)).collect::<Vec<_>>();
 
         let mut regions = ty.regions();
         regions.retain(|r| !r.is_late_bound()); // ignore late-bound regions
index d709a4debd1d38bedc8d4e2f71a79a8faacfb6df..b6cb336648bc7c43542ba442dad4fa29b719841f 100644 (file)
@@ -36,8 +36,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/")]
index 5c1009fb31f19b840a1398c9b3d3522a5d6b4823..14cfaa8153377d76f1adbdcc6c5acac35ffc2a66 100644 (file)
@@ -219,7 +219,7 @@ pub fn register_future_incompatible(&mut self,
             }
         }
 
-        let mut future_incompatible = vec![];
+        let mut future_incompatible = Vec::with_capacity(lints.len());
         for lint in lints {
             future_incompatible.push(lint.id);
             self.future_incompatible.insert(lint.id, lint);
index 6f5791ed5d71bc063c11a69b1b3a10e4525b3eef..c8d513a59f00de4776015a98a67b7107aee3060a 100644 (file)
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
                                            StableHasherResult};
 
+#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
+pub enum SignalledError { SawSomeError, NoErrorsSeen }
+
+impl_stable_hash_for!(enum self::SignalledError { SawSomeError, NoErrorsSeen });
+
 #[derive(Debug, RustcEncodable, RustcDecodable)]
 pub struct BorrowCheckResult {
     pub used_mut_nodes: FxHashSet<HirId>,
+    pub signalled_any_error: SignalledError,
 }
 
 impl<'a> HashStable<StableHashingContext<'a>> for BorrowCheckResult {
@@ -26,7 +32,9 @@ fn hash_stable<W: StableHasherResult>(&self,
                                           hasher: &mut StableHasher<W>) {
         let BorrowCheckResult {
             ref used_mut_nodes,
+            ref signalled_any_error,
         } = *self;
         used_mut_nodes.hash_stable(hcx, hasher);
+        signalled_any_error.hash_stable(hcx, hasher);
     }
 }
index 54d9e24bbc0e237134ff86936435643b41ab18a2..9fbf4e7c6a0f4fb965ded3488bf3a840aea73564 100644 (file)
@@ -455,15 +455,28 @@ pub enum BorrowckMode {
     Ast,
     Mir,
     Compare,
+    Migrate,
 }
 
 impl BorrowckMode {
+    /// Should we run the MIR-based borrow check, but also fall back
+    /// on the AST borrow check if the MIR-based one errors.
+    pub fn migrate(self) -> bool {
+        match self {
+            BorrowckMode::Ast => false,
+            BorrowckMode::Compare => false,
+            BorrowckMode::Mir => false,
+            BorrowckMode::Migrate => true,
+        }
+    }
+
     /// Should we emit the AST-based borrow checker errors?
     pub fn use_ast(self) -> bool {
         match self {
             BorrowckMode::Ast => true,
             BorrowckMode::Compare => true,
             BorrowckMode::Mir => false,
+            BorrowckMode::Migrate => false,
         }
     }
     /// Should we emit the MIR-based borrow checker errors?
@@ -472,6 +485,7 @@ pub fn use_mir(self) -> bool {
             BorrowckMode::Ast => false,
             BorrowckMode::Compare => true,
             BorrowckMode::Mir => true,
+            BorrowckMode::Migrate => true,
         }
     }
 }
@@ -1127,7 +1141,7 @@ fn parse_cross_lang_lto(slot: &mut CrossLangLto, v: Option<&str>) -> bool {
     emit_end_regions: bool = (false, parse_bool, [UNTRACKED],
         "emit EndRegion as part of MIR; enable transforms that solely process EndRegion"),
     borrowck: Option<String> = (None, parse_opt_string, [UNTRACKED],
-        "select which borrowck is used (`ast`, `mir`, or `compare`)"),
+        "select which borrowck is used (`ast`, `mir`, `migrate`, or `compare`)"),
     two_phase_borrows: bool = (false, parse_bool, [UNTRACKED],
         "use two-phase reserved/active distinction for `&mut` borrows in MIR borrowck"),
     two_phase_beyond_autoref: bool = (false, parse_bool, [UNTRACKED],
@@ -1233,8 +1247,6 @@ fn parse_cross_lang_lto(slot: &mut CrossLangLto, v: Option<&str>) -> bool {
           "for every macro invocation, print its name and arguments"),
     debug_macros: bool = (false, parse_bool, [TRACKED],
           "emit line numbers debug info inside macros"),
-    enable_nonzeroing_move_hints: bool = (false, parse_bool, [TRACKED],
-          "force nonzeroing move optimization on"),
     keep_hygiene_data: bool = (false, parse_bool, [UNTRACKED],
           "don't clear the hygiene data after analysis"),
     keep_ast: bool = (false, parse_bool, [UNTRACKED],
@@ -2168,6 +2180,7 @@ pub fn build_session_options_and_crate_config(
         None | Some("ast") => BorrowckMode::Ast,
         Some("mir") => BorrowckMode::Mir,
         Some("compare") => BorrowckMode::Compare,
+        Some("migrate") => BorrowckMode::Migrate,
         Some(m) => early_error(error_format, &format!("unknown borrowck mode `{}`", m)),
     };
 
@@ -3153,10 +3166,6 @@ fn test_debugging_options_tracking_hash() {
         opts.debugging_opts.force_overflow_checks = Some(true);
         assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
 
-        opts = reference.clone();
-        opts.debugging_opts.enable_nonzeroing_move_hints = true;
-        assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
-
         opts = reference.clone();
         opts.debugging_opts.show_span = Some(String::from("abc"));
         assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
index 77a1129f66d27726dc67aab94a3bec227a88a177..7b8bbbf4a10e061eb83becc03886f980e460ff5f 100644 (file)
@@ -624,9 +624,6 @@ pub fn no_landing_pads(&self) -> bool {
     pub fn unstable_options(&self) -> bool {
         self.opts.debugging_opts.unstable_options
     }
-    pub fn nonzeroing_move_hints(&self) -> bool {
-        self.opts.debugging_opts.enable_nonzeroing_move_hints
-    }
     pub fn overflow_checks(&self) -> bool {
         self.opts
             .cg
index 83128ba75d5827e25ef060703e1ffc20b02b2a15..aa4f63675d7341dbab16834fc61ecf64c88fc3f5 100644 (file)
@@ -98,13 +98,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
     pub fn astconv_object_safety_violations(self, trait_def_id: DefId)
                                             -> Vec<ObjectSafetyViolation>
     {
-        let mut violations = vec![];
-
-        for def_id in traits::supertrait_def_ids(self, trait_def_id) {
-            if self.predicates_reference_self(def_id, true) {
-                violations.push(ObjectSafetyViolation::SupertraitSelf);
-            }
-        }
+        let violations = traits::supertrait_def_ids(self, trait_def_id)
+            .filter(|&def_id| self.predicates_reference_self(def_id, true))
+            .map(|_| ObjectSafetyViolation::SupertraitSelf)
+            .collect();
 
         debug!("astconv_object_safety_violations(trait_def_id={:?}) = {:?}",
                trait_def_id,
index 1052d029e0d648e5a0f11f2ffbf51c7bebf01f79..1ce60d8f05599e630905b5cf04fa5571106c8492 100644 (file)
@@ -1502,7 +1502,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
     let param_env = obligation.param_env;
     let assoc_ty = assoc_ty_def(selcx, impl_def_id, obligation.predicate.item_def_id);
 
-    let ty = if !assoc_ty.item.defaultness.has_value() {
+    if !assoc_ty.item.defaultness.has_value() {
         // This means that the impl is missing a definition for the
         // associated type. This error will be reported by the type
         // checker method `check_impl_items_against_trait`, so here we
@@ -1510,11 +1510,18 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
         debug!("confirm_impl_candidate: no associated type {:?} for {:?}",
                assoc_ty.item.ident,
                obligation.predicate);
-        tcx.types.err
+        return Progress {
+            ty: tcx.types.err,
+            obligations: nested,
+        };
+    }
+    let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
+    let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind {
+        let item_substs = Substs::identity_for_item(tcx, assoc_ty.item.def_id);
+        tcx.mk_anon(assoc_ty.item.def_id, item_substs)
     } else {
         tcx.type_of(assoc_ty.item.def_id)
     };
-    let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
     Progress {
         ty: ty.subst(tcx, substs),
         obligations: nested,
index b64e4228be9d21abae26c245aca4e7ff23bd30fc..6562526a2ea731822db752323746c43c374ebcb3 100644 (file)
@@ -377,9 +377,19 @@ pub fn defs(
         trait_def_id: DefId,
     ) -> impl Iterator<Item = NodeItem<ty::AssociatedItem>> + Captures<'gcx> + Captures<'tcx> + 'a {
         self.flat_map(move |node| {
-            node.items(tcx).filter(move |impl_item| {
-                impl_item.kind == trait_item_kind &&
-                tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id)
+            use ty::AssociatedKind::*;
+            node.items(tcx).filter(move |impl_item| match (trait_item_kind, impl_item.kind) {
+                | (Const, Const)
+                | (Method, Method)
+                | (Type, Type)
+                | (Type, Existential)
+                => tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id),
+
+                | (Const, _)
+                | (Method, _)
+                | (Type, _)
+                | (Existential, _)
+                => false,
             }).map(move |item| NodeItem { node: node, item: item })
         })
     }
index 41007508c506010c2e73c1e012300073ab758c0f..98568f860a4fdd62ee33a4728de581a85a31612e 100644 (file)
@@ -74,6 +74,7 @@
 use syntax::ast::{self, NodeId};
 use syntax::attr;
 use syntax::codemap::MultiSpan;
+use syntax::edition::Edition;
 use syntax::feature_gate;
 use syntax::symbol::{Symbol, keywords, InternedString};
 use syntax_pos::Span;
@@ -1366,6 +1367,12 @@ pub fn use_mir_borrowck(self) -> bool {
         self.borrowck_mode().use_mir()
     }
 
+    /// If true, we should use the MIR-based borrow check, but also
+    /// fall back on the AST borrow check if the MIR-based one errors.
+    pub fn migrate_borrowck(self) -> bool {
+        self.borrowck_mode().migrate()
+    }
+
     /// If true, make MIR codegen for `match` emit a temp that holds a
     /// borrow of the input to the match expression.
     pub fn generate_borrow_of_any_match_input(&self) -> bool {
@@ -1397,18 +1404,51 @@ pub fn two_phase_borrows(self) -> bool {
     /// What mode(s) of borrowck should we run? AST? MIR? both?
     /// (Also considers the `#![feature(nll)]` setting.)
     pub fn borrowck_mode(&self) -> BorrowckMode {
-        match self.sess.opts.borrowck_mode {
-            mode @ BorrowckMode::Mir |
-            mode @ BorrowckMode::Compare => mode,
+        // Here are the main constraints we need to deal with:
+        //
+        // 1. An opts.borrowck_mode of `BorrowckMode::Ast` is
+        //    synonymous with no `-Z borrowck=...` flag at all.
+        //    (This is arguably a historical accident.)
+        //
+        // 2. `BorrowckMode::Migrate` is the limited migration to
+        //    NLL that we are deploying with the 2018 edition.
+        //
+        // 3. We want to allow developers on the Nightly channel
+        //    to opt back into the "hard error" mode for NLL,
+        //    (which they can do via specifying `#![feature(nll)]`
+        //    explicitly in their crate).
+        //
+        // So, this precedence list is how pnkfelix chose to work with
+        // the above constraints:
+        //
+        // * `#![feature(nll)]` *always* means use NLL with hard
+        //   errors. (To simplify the code here, it now even overrides
+        //   a user's attempt to specify `-Z borrowck=compare`, which
+        //   we arguably do not need anymore and should remove.)
+        //
+        // * Otherwise, if no `-Z borrowck=...` flag was given (or
+        //   if `borrowck=ast` was specified), then use the default
+        //   as required by the edition.
+        //
+        // * Otherwise, use the behavior requested via `-Z borrowck=...`
 
-            mode @ BorrowckMode::Ast => {
-                if self.features().nll {
-                    BorrowckMode::Mir
-                } else {
-                    mode
-                }
-            }
+        if self.features().nll { return BorrowckMode::Mir; }
 
+        match self.sess.opts.borrowck_mode {
+            mode @ BorrowckMode::Mir |
+            mode @ BorrowckMode::Compare |
+            mode @ BorrowckMode::Migrate => mode,
+
+            BorrowckMode::Ast => match self.sess.edition() {
+                Edition::Edition2015 => BorrowckMode::Ast,
+                Edition::Edition2018 => BorrowckMode::Migrate,
+
+                // For now, future editions mean Migrate. (But it
+                // would make a lot of sense for it to be changed to
+                // `BorrowckMode::Mir`, depending on how we plan to
+                // time the forcing of full migration to NLL.)
+                _ => BorrowckMode::Migrate,
+            },
         }
     }
 
index c67453d2b201a9bce0efe1bb3f3694872abb22fd..15b5edaa3d5d75d91d08c7d36fbcc42bb14754c4 100644 (file)
@@ -19,7 +19,7 @@
 use ty::{TyParam, TyRawPtr, TyRef, TyNever, TyTuple};
 use ty::{TyClosure, TyGenerator, TyGeneratorWitness, TyForeign, TyProjection, TyAnon};
 use ty::{TyDynamic, TyInt, TyUint, TyInfer};
-use ty::{self, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
+use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
 use util::nodemap::FxHashSet;
 
 use std::cell::Cell;
 use syntax::symbol::{Symbol, InternedString};
 use hir;
 
+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<Option<(RegionVid, usize)>> = Cell::new(None)
+}
+
 macro_rules! gen_display_debug_body {
     ( $with:path ) => {
         fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -562,6 +568,19 @@ pub fn parameterized<F: fmt::Write>(f: &mut F,
     PrintContext::new().parameterized(f, substs, did, projections)
 }
 
+fn get_highlight_region() -> Option<(RegionVid, usize)> {
+    HIGHLIGHT_REGION.with(|hr| hr.get())
+}
+
+pub fn with_highlight_region<R>(r: RegionVid, counter: usize, op: impl FnOnce() -> R) -> R {
+    HIGHLIGHT_REGION.with(|hr| {
+        assert_eq!(hr.get(), None);
+        hr.set(Some((r, counter)));
+        let r = op();
+        hr.set(None);
+        r
+    })
+}
 
 impl<'a, T: Print> Print for &'a T {
     fn print<F: fmt::Write>(&self, f: &mut F, cx: &mut PrintContext) -> fmt::Result {
@@ -733,7 +752,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 define_print! {
     () ty::RegionKind, (self, f, cx) {
         display {
-            if cx.is_verbose {
+            if cx.is_verbose || get_highlight_region().is_some() {
                 return self.print_debug(f, cx);
             }
 
@@ -905,6 +924,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 impl fmt::Debug for ty::RegionVid {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        if let Some((region, counter)) = get_highlight_region() {
+            debug!("RegionVid.fmt: region={:?} self={:?} counter={:?}", region, self, counter);
+            return if *self == region {
+                write!(f, "'{:?}", counter)
+            } else {
+                write!(f, "'_")
+            }
+        }
+
         write!(f, "'_#{}r", self.index())
     }
 }
@@ -1022,9 +1050,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 TyRef(r, ty, mutbl) => {
                     write!(f, "&")?;
                     let s = r.print_to_string(cx);
-                    write!(f, "{}", s)?;
-                    if !s.is_empty() {
-                        write!(f, " ")?;
+                    if s != "'_" {
+                        write!(f, "{}", s)?;
+                        if !s.is_empty() {
+                            write!(f, " ")?;
+                        }
                     }
                     ty::TypeAndMut { ty, mutbl }.print(f, cx)
                 }
index 1227936ce96fc89a3cdc5352918e8d253b59cb2c..b217d3665a24542306a6dceb838acbf80f7ab428 100644 (file)
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
 #![feature(rustc_private)]
 
 #[macro_use] extern crate log;
index c7cd958016dca5b1d3c140812c66ca6028b4c430..08438805a703e759f5823ab6b4a1a7b830dc616b 100644 (file)
@@ -40,8 +40,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
index 7bd1e98f85dc2fa553b1ebd0e3510e9cc3e65462..0c78fd74a234ee01091ae813c400b30afc8c575f 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![sanitizer_runtime]
 #![feature(alloc_system)]
 #![feature(sanitizer_runtime)]
index 002e8697588fcdb113b5ea66ad85ff9dd81c0071..49bd69f8262169ad18bb2a85daa9cb487bbdf9ca 100644 (file)
@@ -447,10 +447,12 @@ pub fn borrow_of_local_data<'tcx>(cmt: &mc::cmt_<'tcx>) -> bool {
                                       .region_scope_tree
                                       .yield_in_scope_for_expr(scope,
                                                                cmt.hir_id,
-                                                               self.bccx.body) {
+                                                               self.bccx.body)
+        {
             self.bccx.cannot_borrow_across_generator_yield(borrow_span,
                                                            yield_span,
                                                            Origin::Ast).emit();
+            self.bccx.signal_error();
         }
     }
 
@@ -507,9 +509,13 @@ pub fn report_error_if_loans_conflict(&self,
             new_loan, old_loan, old_loan, new_loan).err();
 
         match (err_old_new, err_new_old) {
-            (Some(mut err), None) | (None, Some(mut err)) => err.emit(),
+            (Some(mut err), None) | (None, Some(mut err)) => {
+                err.emit();
+                self.bccx.signal_error();
+            }
             (Some(mut err_old), Some(mut err_new)) => {
                 err_old.emit();
+                self.bccx.signal_error();
                 err_new.cancel();
             }
             (None, None) => return true,
@@ -695,6 +701,7 @@ fn check_for_copy_of_frozen_path(&self,
                         loan_span, &self.bccx.loan_path_to_string(&loan_path),
                         Origin::Ast)
                     .emit();
+                self.bccx.signal_error();
             }
         }
     }
@@ -745,6 +752,7 @@ fn check_for_move_of_borrowed_path(&self,
                 };
 
                 err.emit();
+                self.bccx.signal_error();
             }
         }
     }
@@ -914,5 +922,6 @@ pub fn report_illegal_mutation(&self,
         self.bccx.cannot_assign_to_borrowed(
             span, loan.span, &self.bccx.loan_path_to_string(loan_path), Origin::Ast)
             .emit();
+        self.bccx.signal_error();
     }
 }
index f221565c7f39124afc001be0819ed538f86c84f4..e51caf89ee651b39e7ddc46feb10adc51809ca8f 100644 (file)
@@ -99,6 +99,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, errors: &Vec<Move
                            "captured outer variable");
         }
         err.emit();
+        bccx.signal_error();
     }
 }
 
index 3ae1e5aac507611938bc57855c1d5f18200720db..0cb4a766e807997d79b5cabfcd981c98fa29d874 100644 (file)
@@ -28,7 +28,7 @@
 use rustc::middle::dataflow::BitwiseOperator;
 use rustc::middle::dataflow::DataFlowOperator;
 use rustc::middle::dataflow::KillFrom;
-use rustc::middle::borrowck::BorrowCheckResult;
+use rustc::middle::borrowck::{BorrowCheckResult, SignalledError};
 use rustc::hir::def_id::{DefId, LocalDefId};
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::mem_categorization as mc;
@@ -42,7 +42,7 @@
 use rustc_mir::util::suggest_ref_mut;
 use rustc::util::nodemap::FxHashSet;
 
-use std::cell::RefCell;
+use std::cell::{Cell, RefCell};
 use std::fmt;
 use std::rc::Rc;
 use rustc_data_structures::sync::Lrc;
@@ -90,7 +90,7 @@ pub struct AnalysisData<'a, 'tcx: 'a> {
 fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
     -> Lrc<BorrowCheckResult>
 {
-    assert!(tcx.use_ast_borrowck());
+    assert!(tcx.use_ast_borrowck() || tcx.migrate_borrowck());
 
     debug!("borrowck(body_owner_def_id={:?})", owner_def_id);
 
@@ -105,6 +105,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
             // and do not need borrowchecking.
             return Lrc::new(BorrowCheckResult {
                 used_mut_nodes: FxHashSet(),
+                signalled_any_error: SignalledError::NoErrorsSeen,
             })
         }
         _ => { }
@@ -121,6 +122,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
         owner_def_id,
         body,
         used_mut_nodes: RefCell::new(FxHashSet()),
+        signalled_any_error: Cell::new(SignalledError::NoErrorsSeen),
     };
 
     // Eventually, borrowck will always read the MIR, but at the
@@ -154,6 +156,7 @@ fn borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, owner_def_id: DefId)
 
     Lrc::new(BorrowCheckResult {
         used_mut_nodes: bccx.used_mut_nodes.into_inner(),
+        signalled_any_error: bccx.signalled_any_error.into_inner(),
     })
 }
 
@@ -234,6 +237,7 @@ pub fn build_borrowck_dataflow_data_for_fn<'a, 'tcx>(
         owner_def_id,
         body,
         used_mut_nodes: RefCell::new(FxHashSet()),
+        signalled_any_error: Cell::new(SignalledError::NoErrorsSeen),
     };
 
     let dataflow_data = build_borrowck_dataflow_data(&mut bccx, true, body_id, |_| cfg);
@@ -257,6 +261,15 @@ pub struct BorrowckCtxt<'a, 'tcx: 'a> {
     body: &'tcx hir::Body,
 
     used_mut_nodes: RefCell<FxHashSet<HirId>>,
+
+    signalled_any_error: Cell<SignalledError>,
+}
+
+
+impl<'a, 'tcx: 'a> BorrowckCtxt<'a, 'tcx> {
+    fn signal_error(&self) {
+        self.signalled_any_error.set(SignalledError::SawSomeError);
+    }
 }
 
 impl<'a, 'b, 'tcx: 'b> BorrowckErrors<'a> for &'a BorrowckCtxt<'b, 'tcx> {
@@ -645,6 +658,7 @@ pub fn report_use_of_moved_value(&self,
                     .span_label(use_span, format!("use of possibly uninitialized `{}`",
                                                   self.loan_path_to_string(lp)))
                     .emit();
+                self.signal_error();
                 return;
             }
             _ => {
@@ -760,6 +774,7 @@ pub fn report_use_of_moved_value(&self,
         // not considered particularly helpful.
 
         err.emit();
+        self.signal_error();
     }
 
     pub fn report_partial_reinitialization_of_uninitialized_structure(
@@ -770,6 +785,7 @@ pub fn report_partial_reinitialization_of_uninitialized_structure(
                                                       &self.loan_path_to_string(lp),
                                                       Origin::Ast)
             .emit();
+        self.signal_error();
     }
 
     pub fn report_reassigned_immutable_variable(&self,
@@ -787,6 +803,7 @@ pub fn report_reassigned_immutable_variable(&self,
                                                 self.loan_path_to_string(lp)));
         }
         err.emit();
+        self.signal_error();
     }
 
     pub fn struct_span_err_with_code<S: Into<MultiSpan>>(&self,
@@ -908,6 +925,7 @@ fn report_bckerr(&self, err: &BckError<'a, 'tcx>) {
                     self.tcx.hir.hir_to_node_id(err.cmt.hir_id)
                 );
                 db.emit();
+                self.signal_error();
             }
             err_out_of_scope(super_scope, sub_scope, cause) => {
                 let msg = match opt_loan_path(&err.cmt) {
@@ -1022,6 +1040,7 @@ fn report_bckerr(&self, err: &BckError<'a, 'tcx>) {
                 }
 
                 db.emit();
+                self.signal_error();
             }
             err_borrowed_pointer_too_short(loan_scope, ptr_scope) => {
                 let descr = self.cmt_to_path_or_string(err.cmt);
@@ -1047,6 +1066,7 @@ fn report_bckerr(&self, err: &BckError<'a, 'tcx>) {
                     "");
 
                 db.emit();
+                self.signal_error();
             }
         }
     }
@@ -1125,6 +1145,7 @@ pub fn report_aliasability_violation(&self,
             err.help("closures behind references must be called via `&mut`");
         }
         err.emit();
+        self.signal_error();
     }
 
     /// Given a type, if it is an immutable reference, return a suggestion to make it mutable
@@ -1307,6 +1328,7 @@ fn report_out_of_scope_escaping_closure_capture(&self,
                                        cmt_path_or_string),
                              suggestion)
             .emit();
+        self.signal_error();
     }
 
     fn region_end_span(&self, region: ty::Region<'tcx>) -> Option<Span> {
index d583a32c43198b40a045ec0a67b9914d2a40a721..a5a20af0e4e4ae880558ce2a5bbd653984987c65 100644 (file)
@@ -13,7 +13,6 @@
       html_root_url = "https://doc.rust-lang.org/nightly/")]
 
 #![allow(non_camel_case_types)]
-#![deny(bare_trait_objects)]
 
 #![feature(from_ref)]
 #![feature(quote)]
index f2b17584adcba2dd517ee9d6e1adff117d9ae3ec..13f0c90e8855e7efd5d20c5e8a4a27da47af6433 100644 (file)
@@ -40,6 +40,7 @@
 use std::fmt;
 use std::fs;
 use std::io;
+use std::iter;
 use std::path::{Path, PathBuf};
 use std::process::{Output, Stdio};
 use std::str;
@@ -885,9 +886,9 @@ fn exec_linker(sess: &Session, cmd: &mut Command, out_filename: &Path, tmpdir: &
     }
     let file = tmpdir.join("linker-arguments");
     let bytes = if sess.target.target.options.is_like_msvc {
-        let mut out = vec![];
+        let mut out = Vec::with_capacity((1 + args.len()) * 2);
         // start the stream with a UTF-16 BOM
-        for c in vec![0xFEFF].into_iter().chain(args.encode_utf16()) {
+        for c in iter::once(0xFEFF).chain(args.encode_utf16()) {
             // encode in little endian
             out.push(c as u8);
             out.push((c >> 8) as u8);
index 8aa7902021f240891e2b8686c43b7e2f0931a136..90f96c9687bc146de2642a2a90e0f729c9ac8875 100644 (file)
@@ -23,7 +23,6 @@
 #![feature(custom_attribute)]
 #![feature(fs_read_write)]
 #![allow(unused_attributes)]
-#![deny(bare_trait_objects)]
 #![feature(libc)]
 #![feature(quote)]
 #![feature(range_contains)]
index e9031007a4eedbdce4b6b6d50035c925c16adbc6..f59cf5832fcb4eb7a423364ca8d9059626332c0e 100644 (file)
@@ -20,7 +20,6 @@
 #![feature(box_syntax)]
 #![feature(custom_attribute)]
 #![allow(unused_attributes)]
-#![deny(bare_trait_objects)]
 #![feature(quote)]
 #![feature(rustc_diagnostic_macros)]
 
index ef0d57c7b7ce7a6bc7b6a8b82232892a84ee0b3c..a9e582e510e7850c1248581908af5593882cb24d 100644 (file)
@@ -16,8 +16,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![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://doc.rust-lang.org/nightly/")]
index 000025c49a698a4a230eb93819d370b0254851ad..9e818641dec71b20aa6a17fdf5a0dbd3035868c7 100644 (file)
@@ -14,8 +14,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
index b1578b697bb8c3e1f389d68fe16f911d72269fdf..825e31539c8bedfe511056858a3182fc10836e3c 100644 (file)
@@ -99,6 +99,25 @@ pub fn new_with_code(level: Level, code: Option<DiagnosticId>, message: &str) ->
         }
     }
 
+    pub fn is_error(&self) -> bool {
+        match self.level {
+            Level::Bug |
+            Level::Fatal |
+            Level::PhaseFatal |
+            Level::Error |
+            Level::FailureNote => {
+                true
+            }
+
+            Level::Warning |
+            Level::Note |
+            Level::Help |
+            Level::Cancelled => {
+                false
+            }
+        }
+    }
+
     /// Cancel the diagnostic (a structured diagnostic must either be emitted or
     /// canceled or it will panic when dropped).
     pub fn cancel(&mut self) {
index 8f99ad87cb8e023699640a6d49f5d056d93f167c..a0f3abda077f94720015a1053c7b57a582788a1f 100644 (file)
@@ -100,25 +100,6 @@ pub fn buffer(self, buffered_diagnostics: &mut Vec<Diagnostic>) {
         buffered_diagnostics.push(diagnostic);
     }
 
-    pub fn is_error(&self) -> bool {
-        match self.level {
-            Level::Bug |
-            Level::Fatal |
-            Level::PhaseFatal |
-            Level::Error |
-            Level::FailureNote => {
-                true
-            }
-
-            Level::Warning |
-            Level::Note |
-            Level::Help |
-            Level::Cancelled => {
-                false
-            }
-        }
-    }
-
     /// Convenience function for internal use, clients should use one of the
     /// span_* methods instead.
     pub fn sub<S: Into<MultiSpan>>(
index c0f07645f496ad7879962c8d0ab16d44a33efeee..67d2aa4d770b98af31163b07224e2a91144f2571 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
index 2ef88041d338f67c5ce4894213f1d3efef14b83b..3839c133a6eb22692d99b1bd8b4597257299c184 100644 (file)
@@ -10,8 +10,6 @@
 
 //! Support for serializing the dep-graph and reloading it.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
index 798c289ac2f9f4f824dafe2c2458304f291e2a99..78a8c494f48c53e5d4f09c85199608a5921d6c76 100644 (file)
@@ -19,8 +19,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
index c60016cde0d1b829de5ca73eae4d6976b74d40a7..741758cb954ba4b38e644c4644ddf57f2546e9cb 100644 (file)
@@ -12,7 +12,6 @@
 #![allow(non_camel_case_types)]
 #![allow(non_snake_case)]
 #![allow(dead_code)]
-#![deny(bare_trait_objects)]
 
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
index 7bd1e98f85dc2fa553b1ebd0e3510e9cc3e65462..0c78fd74a234ee01091ae813c400b30afc8c575f 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![sanitizer_runtime]
 #![feature(alloc_system)]
 #![feature(sanitizer_runtime)]
index d7da0d00012e15261e1ffd2f4c7df5271bf374a6..182a071277ece97d193ec156af5951745a649c3d 100644 (file)
@@ -90,30 +90,29 @@ mod tests {
     use std::mem;
 
     #[test]
-    fn test_loading_cosine() {
+    fn test_loading_atoi() {
         if cfg!(windows) {
             return
         }
 
-        // The math library does not need to be loaded since it is already
-        // statically linked in
-        let libm = match DynamicLibrary::open(None) {
+        // The C library does not need to be loaded since it is already linked in
+        let lib = match DynamicLibrary::open(None) {
             Err(error) => panic!("Could not load self as module: {}", error),
-            Ok(libm) => libm
+            Ok(lib) => lib
         };
 
-        let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe {
-            match libm.symbol("cos") {
-                Err(error) => panic!("Could not load function cos: {}", error),
-                Ok(cosine) => mem::transmute::<*mut u8, _>(cosine)
+        let atoi: extern fn(*const libc::c_char) -> libc::c_int = unsafe {
+            match lib.symbol("atoi") {
+                Err(error) => panic!("Could not load function atoi: {}", error),
+                Ok(atoi) => mem::transmute::<*mut u8, _>(atoi)
             }
         };
 
-        let argument = 0.0;
-        let expected_result = 1.0;
-        let result = cosine(argument);
+        let argument = CString::new("1383428980").unwrap();
+        let expected_result = 0x52757374;
+        let result = atoi(argument.as_ptr());
         if result != expected_result {
-            panic!("cos({}) != {} but equaled {} instead", argument,
+            panic!("atoi({:?}) != {} but equaled {} instead", argument,
                    expected_result, result)
         }
     }
index d535c1ef90357d0c83da785a571ec9dbb3bee160..5cba0387d17bb6ba4ff46ae92076c47a6954051e 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/")]
index e9e0c5c36135322c7594209307c627ec4cae2df8..347bf61480ee4e9356e29bbcee2c0e80f1c553de 100644 (file)
@@ -333,14 +333,21 @@ fn insert_as_pending_if_two_phase(
 
         // Consider the borrow not activated to start. When we find an activation, we'll update
         // this field.
-        let borrow_data = &mut self.idx_vec[borrow_index];
-        borrow_data.activation_location = TwoPhaseActivation::NotActivated;
+        {
+            let borrow_data = &mut self.idx_vec[borrow_index];
+            borrow_data.activation_location = TwoPhaseActivation::NotActivated;
+        }
 
         // Insert `temp` into the list of pending activations. From
         // now on, we'll be on the lookout for a use of it. Note that
         // we are guaranteed that this use will come after the
         // assignment.
         let old_value = self.pending_activations.insert(temp, borrow_index);
-        assert!(old_value.is_none());
+        if let Some(old_index) = old_value {
+            span_bug!(self.mir.source_info(start_location).span,
+                      "found already pending activation for temp: {:?} \
+                       at borrow_index: {:?} with associated data {:?}",
+                      temp, old_index, self.idx_vec[old_index]);
+        }
     }
 }
index 84e3ecd509687cba5a3dfc9fcded7513656cbf49..4ba96f643b0ccaf1b9f66b2203ff2384f0122ba9 100644 (file)
@@ -16,6 +16,7 @@
 use rustc::hir::map::definitions::DefPathData;
 use rustc::infer::InferCtxt;
 use rustc::lint::builtin::UNUSED_MUT;
+use rustc::middle::borrowck::SignalledError;
 use rustc::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind};
 use rustc::mir::{ClearCrossCrate, Local, Location, Mir, Mutability, Operand, Place};
 use rustc::mir::{Field, Projection, ProjectionElem, Rvalue, Statement, StatementKind};
@@ -23,7 +24,7 @@
 use rustc::ty::query::Providers;
 use rustc::ty::{self, ParamEnv, TyCtxt};
 
-use rustc_errors::{Diagnostic, DiagnosticBuilder};
+use rustc_errors::{Diagnostic, DiagnosticBuilder, Level};
 use rustc_data_structures::graph::dominators::Dominators;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::indexed_set::IdxSetBuf;
@@ -329,8 +330,34 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
         }
     }
 
-    for diag in mbcx.errors_buffer.drain(..) {
-        DiagnosticBuilder::new_diagnostic(mbcx.tcx.sess.diagnostic(), diag).emit();
+    if mbcx.errors_buffer.len() > 0 {
+        if tcx.migrate_borrowck() {
+            match tcx.borrowck(def_id).signalled_any_error {
+                SignalledError::NoErrorsSeen => {
+                    // if AST-borrowck signalled no errors, then
+                    // downgrade all the buffered MIR-borrowck errors
+                    // to warnings.
+                    for err in &mut mbcx.errors_buffer {
+                        if err.is_error() {
+                            err.level = Level::Warning;
+                            err.warn("This error has been downgraded to a warning \
+                                      for backwards compatibility with previous releases.\n\
+                                      It represents potential unsoundness in your code.\n\
+                                      This warning will become a hard error in the future.");
+                        }
+                    }
+                }
+                SignalledError::SawSomeError => {
+                    // if AST-borrowck signalled a (cancelled) error,
+                    // then we will just emit the buffered
+                    // MIR-borrowck errors as normal.
+                }
+            }
+        }
+
+        for diag in mbcx.errors_buffer.drain(..) {
+            DiagnosticBuilder::new_diagnostic(mbcx.tcx.sess.diagnostic(), diag).emit();
+        }
     }
 
     let result = BorrowCheckResult {
@@ -1747,20 +1774,44 @@ fn check_access_permissions(
                 }
             }
 
-            Reservation(WriteKind::Move)
-            | Write(WriteKind::Move)
-            | Reservation(WriteKind::StorageDeadOrDrop)
-            | Reservation(WriteKind::MutableBorrow(BorrowKind::Shared))
-            | Write(WriteKind::StorageDeadOrDrop)
-            | Write(WriteKind::MutableBorrow(BorrowKind::Shared)) => {
+            Reservation(wk @ WriteKind::Move)
+            | Write(wk @ WriteKind::Move)
+            | Reservation(wk @ WriteKind::StorageDeadOrDrop)
+            | Reservation(wk @ WriteKind::MutableBorrow(BorrowKind::Shared))
+            | Write(wk @ WriteKind::StorageDeadOrDrop)
+            | Write(wk @ WriteKind::MutableBorrow(BorrowKind::Shared)) => {
                 if let Err(_place_err) = self.is_mutable(place, is_local_mutation_allowed) {
-                    self.tcx.sess.delay_span_bug(
-                        span,
-                        &format!(
-                            "Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
-                            place, kind
-                        ),
-                    );
+                    if self.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
+                        // here). But we can legitimately get here
+                        // under borrowck=migrate mode, so instead of
+                        // ICE'ing we instead report a legitimate
+                        // error (which will then be downgraded to a
+                        // warning by the migrate machinery).
+                        error_access = match wk {
+                            WriteKind::MutableBorrow(_) => AccessKind::MutableBorrow,
+                            WriteKind::Move => AccessKind::Move,
+                            WriteKind::StorageDeadOrDrop |
+                            WriteKind::Mutate => AccessKind::Mutate,
+                        };
+                        self.report_mutability_error(
+                            place,
+                            span,
+                            _place_err,
+                            error_access,
+                            location,
+                        );
+                    } else {
+                        self.tcx.sess.delay_span_bug(
+                            span,
+                            &format!(
+                                "Accessing `{:?}` with the kind `{:?}` shouldn't be possible",
+                                place, kind
+                            ),
+                        );
+                    }
                 }
                 return false;
             }
index ab1ff1fa347d6323b50599f123ee290fccef31fe..571a1188d49ca836add5afa477611b6d353fc9d1 100644 (file)
@@ -24,6 +24,7 @@
 pub(super) enum AccessKind {
     MutableBorrow,
     Mutate,
+    Move,
 }
 
 impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
@@ -110,6 +111,7 @@ pub(super) fn report_mutability_error(
                     if let Some(desc) = access_place_desc {
                         item_msg = format!("`{}`", desc);
                         reason = match error_access {
+                            AccessKind::Move |
                             AccessKind::Mutate => format!(" which is behind a {}", pointer_type),
                             AccessKind::MutableBorrow => {
                                 format!(", as it is behind a {}", pointer_type)
@@ -160,6 +162,13 @@ pub(super) fn report_mutability_error(
 
 
         let span = match error_access {
+            AccessKind::Move => {
+                err = self.tcx
+                    .cannot_move_out_of(span, &(item_msg + &reason), Origin::Mir);
+                act = "move";
+                acted_on = "moved";
+                span
+            }
             AccessKind::Mutate => {
                 err = self.tcx
                     .cannot_assign(span, &(item_msg + &reason), Origin::Mir);
index 1b540ef74be49e05830e28c9635e08e96cdba54b..c2c5c6771b01fd76d0524ac9adb314869dc9e8ea 100644 (file)
@@ -31,9 +31,7 @@
 enum ConstraintCategory {
     Cast,
     Assignment,
-    AssignmentToUpvar,
     Return,
-    CallArgumentToUpvar,
     CallArgument,
     Other,
     Boring,
@@ -41,16 +39,13 @@ enum ConstraintCategory {
 
 impl fmt::Display for ConstraintCategory {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        // Must end with a space. Allows for empty names to be provided.
         match self {
-            ConstraintCategory::Assignment | ConstraintCategory::AssignmentToUpvar => {
-                write!(f, "assignment")
-            }
-            ConstraintCategory::Return => write!(f, "return"),
-            ConstraintCategory::Cast => write!(f, "cast"),
-            ConstraintCategory::CallArgument | ConstraintCategory::CallArgumentToUpvar => {
-                write!(f, "argument")
-            }
-            _ => write!(f, "free region"),
+            ConstraintCategory::Assignment => write!(f, "assignment "),
+            ConstraintCategory::Return => write!(f, "return "),
+            ConstraintCategory::Cast => write!(f, "cast "),
+            ConstraintCategory::CallArgument => write!(f, "argument "),
+            _ => write!(f, ""),
         }
     }
 }
@@ -224,10 +219,10 @@ fn constraint_is_interesting(&self, index: ConstraintIndex) -> bool {
             "constraint_is_interesting: locations={:?} constraint={:?}",
             constraint.locations, constraint
         );
-        if let Locations::Interesting(_) = constraint.locations {
-            true
-        } else {
-            false
+
+        match constraint.locations {
+            Locations::Interesting(_) | Locations::All => true,
+            _ => false,
         }
     }
 
@@ -320,45 +315,26 @@ pub(super) fn report_error(
             }
         }
 
-        let category = match (
-            category,
+        let (fr_is_local, outlived_fr_is_local): (bool, bool) = (
             self.universal_regions.is_local_free_region(fr),
             self.universal_regions.is_local_free_region(outlived_fr),
-        ) {
-            (ConstraintCategory::Assignment, true, false) => ConstraintCategory::AssignmentToUpvar,
-            (ConstraintCategory::CallArgument, true, false) => {
-                ConstraintCategory::CallArgumentToUpvar
-            }
-            (category, _, _) => category,
+        );
+        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::Assignment, true, false) |
+            (ConstraintCategory::CallArgument, true, false) =>
+                self.report_escaping_data_error(mir, infcx, mir_def_id, fr, outlived_fr,
+                                                category, span, errors_buffer),
+            _ =>
+                self.report_general_error(mir, infcx, mir_def_id, fr, fr_is_local,
+                                          outlived_fr, outlived_fr_is_local,
+                                          category, span, errors_buffer),
         };
-
-        debug!("report_error: category={:?}", category);
-        match category {
-            ConstraintCategory::AssignmentToUpvar | ConstraintCategory::CallArgumentToUpvar => self
-                .report_closure_error(
-                    mir,
-                    infcx,
-                    mir_def_id,
-                    fr,
-                    outlived_fr,
-                    category,
-                    span,
-                    errors_buffer,
-                ),
-            _ => self.report_general_error(
-                mir,
-                infcx,
-                mir_def_id,
-                fr,
-                outlived_fr,
-                category,
-                span,
-                errors_buffer,
-            ),
-        }
     }
 
-    fn report_closure_error(
+    fn report_escaping_data_error(
         &self,
         mir: &Mir<'tcx>,
         infcx: &InferCtxt<'_, '_, 'tcx>,
@@ -373,29 +349,23 @@ fn report_closure_error(
         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" };
+
         if fr_name_and_span.is_none() && outlived_fr_name_and_span.is_none() {
-            return self.report_general_error(
-                mir,
-                infcx,
-                mir_def_id,
-                fr,
-                outlived_fr,
-                category,
-                span,
-                errors_buffer,
-            );
+            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 closure"));
+        let mut diag = infcx.tcx.sess.struct_span_err(
+            span, &format!("borrowed data escapes outside of {}", escapes_from),
+        );
 
         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 closure body", name),
+                    format!("`{}` is declared here, outside of the {} body", name, escapes_from),
                 );
             }
         }
@@ -404,13 +374,12 @@ fn report_closure_error(
             if let Some(name) = fr_name {
                 diag.span_label(
                     fr_span,
-                    format!(
-                        "`{}` is a reference that is only valid in the closure body",
-                        name
-                    ),
+                    format!("`{}` is a reference that is only valid in the {} body",
+                            name, escapes_from),
                 );
 
-                diag.span_label(span, format!("`{}` escapes the closure body here", name));
+                diag.span_label(span, format!("`{}` escapes the {} body here",
+                                               name, escapes_from));
             }
         }
 
@@ -423,7 +392,9 @@ fn report_general_error(
         infcx: &InferCtxt<'_, '_, 'tcx>,
         mir_def_id: DefId,
         fr: RegionVid,
+        fr_is_local: bool,
         outlived_fr: RegionVid,
+        outlived_fr_is_local: bool,
         category: ConstraintCategory,
         span: Span,
         errors_buffer: &mut Vec<Diagnostic>,
@@ -434,17 +405,28 @@ fn report_general_error(
         );
 
         let counter = &mut 1;
-        let fr_name = self.give_region_a_name(infcx.tcx, mir, mir_def_id, fr, counter, &mut diag);
-        let outlived_fr_name =
-            self.give_region_a_name(infcx.tcx, mir, mir_def_id, outlived_fr, counter, &mut diag);
-
-        diag.span_label(
-            span,
-            format!(
-                "{} requires that `{}` must outlive `{}`",
-                category, fr_name, outlived_fr_name,
-            ),
-        );
+        let fr_name = self.give_region_a_name(
+            infcx, mir, mir_def_id, fr, counter, &mut diag);
+        let outlived_fr_name = self.give_region_a_name(
+            infcx, mir, mir_def_id, outlived_fr, counter, &mut diag);
+
+        let mir_def_name = if infcx.tcx.is_closure(mir_def_id) { "closure" } else { "function" };
+
+        match (category, outlived_fr_is_local, fr_is_local) {
+            (ConstraintCategory::Return, true, _) => {
+                diag.span_label(span, format!(
+                    "{} was supposed to return data with lifetime `{}` but it is returning \
+                    data with lifetime `{}`",
+                    mir_def_name, fr_name, outlived_fr_name,
+                ));
+            },
+            _ => {
+                diag.span_label(span, format!(
+                    "{}requires that `{}` must outlive `{}`",
+                    category, fr_name, outlived_fr_name,
+                ));
+            },
+        }
 
         diag.buffer(errors_buffer);
     }
index c0eca026331ba3891b2cef0b85d1e58f0db485b9..8505d8e1ef39c4cca816f36fa3e7398b54f7c74b 100644 (file)
 use borrow_check::nll::ToRegionVid;
 use rustc::hir;
 use rustc::hir::def_id::DefId;
+use rustc::infer::InferCtxt;
 use rustc::mir::Mir;
 use rustc::ty::subst::{Substs, UnpackedKind};
 use rustc::ty::{self, RegionVid, Ty, TyCtxt};
+use rustc::util::ppaux::with_highlight_region;
 use rustc_errors::DiagnosticBuilder;
 use syntax::ast::Name;
 use syntax::symbol::keywords;
@@ -48,7 +50,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
     /// and then return the name `'1` for us to use.
     crate fn give_region_a_name(
         &self,
-        tcx: TyCtxt<'_, '_, 'tcx>,
+        infcx: &InferCtxt<'_, '_, 'tcx>,
         mir: &Mir<'tcx>,
         mir_def_id: DefId,
         fr: RegionVid,
@@ -59,17 +61,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
 
         assert!(self.universal_regions.is_universal_region(fr));
 
-        self.give_name_from_error_region(tcx, mir_def_id, fr, counter, diag)
+        self.give_name_from_error_region(infcx.tcx, mir_def_id, fr, counter, diag)
             .or_else(|| {
                 self.give_name_if_anonymous_region_appears_in_arguments(
-                    tcx, mir, mir_def_id, fr, counter, diag)
+                    infcx, mir, mir_def_id, fr, counter, diag)
             })
             .or_else(|| {
                 self.give_name_if_anonymous_region_appears_in_upvars(
-                    tcx, mir, fr, counter, diag)
+                    infcx.tcx, mir, fr, counter, diag)
             })
             .or_else(|| {
-                self.give_name_if_anonymous_region_appears_in_output(tcx, mir, fr, counter, diag)
+                self.give_name_if_anonymous_region_appears_in_output(
+                    infcx.tcx, mir, fr, counter, diag)
             })
             .unwrap_or_else(|| span_bug!(mir.span, "can't make a name for free region {:?}", fr))
     }
@@ -130,7 +133,7 @@ fn give_name_from_error_region(
     /// ```
     fn give_name_if_anonymous_region_appears_in_arguments(
         &self,
-        tcx: TyCtxt<'_, '_, 'tcx>,
+        infcx: &InferCtxt<'_, '_, 'tcx>,
         mir: &Mir<'tcx>,
         mir_def_id: DefId,
         fr: RegionVid,
@@ -138,12 +141,13 @@ fn give_name_if_anonymous_region_appears_in_arguments(
         diag: &mut DiagnosticBuilder<'_>,
     ) -> Option<InternedString> {
         let implicit_inputs = self.universal_regions.defining_ty.implicit_inputs();
-        let argument_index = self.get_argument_index_for_region(tcx, fr)?;
+        let argument_index = self.get_argument_index_for_region(infcx.tcx, fr)?;
 
         let arg_ty =
             self.universal_regions.unnormalized_input_tys[implicit_inputs + argument_index];
         if let Some(region_name) = self.give_name_if_we_can_match_hir_ty_from_argument(
-            tcx,
+            infcx,
+            mir,
             mir_def_id,
             fr,
             arg_ty,
@@ -169,7 +173,8 @@ fn give_name_if_anonymous_region_appears_in_arguments(
 
     fn give_name_if_we_can_match_hir_ty_from_argument(
         &self,
-        tcx: TyCtxt<'_, '_, 'tcx>,
+        infcx: &InferCtxt<'_, '_, 'tcx>,
+        mir: &Mir<'tcx>,
         mir_def_id: DefId,
         needle_fr: RegionVid,
         argument_ty: Ty<'tcx>,
@@ -177,17 +182,24 @@ fn give_name_if_we_can_match_hir_ty_from_argument(
         counter: &mut usize,
         diag: &mut DiagnosticBuilder<'_>,
     ) -> Option<InternedString> {
-        let mir_node_id = tcx.hir.as_local_node_id(mir_def_id)?;
-        let fn_decl = tcx.hir.fn_decl(mir_node_id)?;
+        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];
         match argument_hir_ty.node {
             // This indicates a variable with no type annotation, like
             // `|x|`... in that case, we can't highlight the type but
             // must highlight the variable.
-            hir::TyKind::Infer => None,
+            hir::TyKind::Infer => self.give_name_if_we_cannot_match_hir_ty(
+                infcx,
+                mir,
+                needle_fr,
+                argument_ty,
+                counter,
+                diag,
+            ),
 
             _ => self.give_name_if_we_can_match_hir_ty(
-                tcx,
+                infcx.tcx,
                 needle_fr,
                 argument_ty,
                 argument_hir_ty,
@@ -197,6 +209,49 @@ fn give_name_if_we_can_match_hir_ty_from_argument(
         }
     }
 
+    /// Attempts to highlight the specific part of a type in an argument
+    /// that has no type annotation.
+    /// For example, we might produce an annotation like this:
+    ///
+    /// ```
+    ///  |     foo(|a, b| b)
+    ///  |          -  -
+    ///  |          |  |
+    ///  |          |  has type `&'1 u32`
+    ///  |          has type `&'2 u32`
+    /// ```
+    fn give_name_if_we_cannot_match_hir_ty(
+        &self,
+        infcx: &InferCtxt<'_, '_, 'tcx>,
+        mir: &Mir<'tcx>,
+        needle_fr: RegionVid,
+        argument_ty: Ty<'tcx>,
+        counter: &mut usize,
+        diag: &mut DiagnosticBuilder<'_>,
+    ) -> Option<InternedString> {
+        let type_name = with_highlight_region(needle_fr, *counter, || {
+            infcx.extract_type_name(&argument_ty)
+        });
+
+        debug!("give_name_if_we_cannot_match_hir_ty: type_name={:?} needle_fr={:?}",
+               type_name, needle_fr);
+        let assigned_region_name = if type_name.find(&format!("'{}", counter)).is_some() {
+            // 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))
+        } else {
+            None
+        };
+
+        assigned_region_name
+    }
+
     /// Attempts to highlight the specific part of a type annotation
     /// that contains the anonymous reference we want to give a name
     /// to. For example, we might produce an annotation like this:
index bbbe757e96ec68fd49f9f27030f9e3ddae0ef867..c3637a5abebdc4e31f9624dd722d0f34d234fbdf 100644 (file)
@@ -16,6 +16,8 @@
 use rustc::hir;
 use syntax_pos::Span;
 
+use std::slice;
+
 impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
     pub fn ast_block(&mut self,
                      destination: &Place<'tcx>,
@@ -126,7 +128,7 @@ fn ast_block_stmts(&mut self,
                             None,
                             remainder_span,
                             lint_level,
-                            &pattern,
+                            slice::from_ref(&pattern),
                             ArmHasGuard(false),
                             Some((None, initializer_span)),
                         );
@@ -138,8 +140,9 @@ fn ast_block_stmts(&mut self,
                                 })
                             }));
                     } else {
-                        scope = this.declare_bindings(None, remainder_span, lint_level, &pattern,
-                                                        ArmHasGuard(false), None);
+                        scope = this.declare_bindings(
+                            None, remainder_span, lint_level, slice::from_ref(&pattern),
+                            ArmHasGuard(false), None);
 
                         // FIXME(#47184): We currently only insert `UserAssertTy` statements for
                         // patterns that are bindings, this is as we do not want to deconstruct
index 964841e7a9ed4c1d8ae29f0bdbeb54862e57a6e4..a38ca7ae5bf64953574c0659126fc4e1ef2fbfd0 100644 (file)
@@ -11,7 +11,7 @@
 //! See docs in build/expr/mod.rs
 
 use build::{BlockAnd, BlockAndExtension, Builder};
-use build::ForGuard::{OutsideGuard, RefWithinGuard, ValWithinGuard};
+use build::ForGuard::{OutsideGuard, RefWithinGuard};
 use build::expr::category::Category;
 use hair::*;
 use rustc::mir::*;
@@ -87,14 +87,11 @@ fn expr_as_place(&mut self,
                 block.and(Place::Local(Local::new(1)))
             }
             ExprKind::VarRef { id } => {
-                let place = if this.is_bound_var_in_guard(id) {
-                    if this.hir.tcx().all_pat_vars_are_implicit_refs_within_guards() {
-                        let index = this.var_local_id(id, RefWithinGuard);
-                        Place::Local(index).deref()
-                    } else {
-                        let index = this.var_local_id(id, ValWithinGuard);
-                        Place::Local(index)
-                    }
+                let place = if this.is_bound_var_in_guard(id) &&
+                    this.hir.tcx().all_pat_vars_are_implicit_refs_within_guards()
+                {
+                    let index = this.var_local_id(id, RefWithinGuard);
+                    Place::Local(index).deref()
                 } else {
                     let index = this.var_local_id(id, OutsideGuard);
                     Place::Local(index)
index 5de316a66403301ab18a43c21d08e479a17c005a..7c9496690280490da58c6aff5d69e07c52e5d18d 100644 (file)
@@ -97,7 +97,7 @@ pub fn match_expr(&mut self,
             let body = self.hir.mirror(arm.body.clone());
             let scope = self.declare_bindings(None, body.span,
                                               LintLevel::Inherited,
-                                              &arm.patterns[0],
+                                              &arm.patterns[..],
                                               ArmHasGuard(arm.guard.is_some()),
                                               Some((Some(&discriminant_place), discriminant_span)));
             (body, scope.unwrap_or(self.source_scope))
@@ -118,11 +118,13 @@ pub fn match_expr(&mut self,
             arms.iter()
                 .enumerate()
                 .flat_map(|(arm_index, arm)| {
-                    arm.patterns.iter()
-                                .map(move |pat| (arm_index, pat, arm.guard.clone()))
+                    arm.patterns.iter().enumerate()
+                        .map(move |(pat_index, pat)| {
+                            (arm_index, pat_index, pat, arm.guard.clone())
+                        })
                 })
                 .zip(pre_binding_blocks.iter().zip(pre_binding_blocks.iter().skip(1)))
-                .map(|((arm_index, pattern, guard),
+                .map(|((arm_index, pat_index, pattern, guard),
                        (pre_binding_block, next_candidate_pre_binding_block))| {
 
                     if let (true, Some(borrow_temp)) = (tcx.emit_read_for_match(),
@@ -168,6 +170,7 @@ pub fn match_expr(&mut self,
                         bindings: vec![],
                         guard,
                         arm_index,
+                        pat_index,
                         pre_binding_block: *pre_binding_block,
                         next_candidate_pre_binding_block: *next_candidate_pre_binding_block,
                     }
@@ -277,6 +280,7 @@ pub fn place_into_pattern(&mut self,
 
             // since we don't call `match_candidates`, next fields is unused
             arm_index: 0,
+            pat_index: 0,
             pre_binding_block: block,
             next_candidate_pre_binding_block: block
         };
@@ -324,14 +328,15 @@ pub fn declare_bindings(&mut self,
                             mut visibility_scope: Option<SourceScope>,
                             scope_span: Span,
                             lint_level: LintLevel,
-                            pattern: &Pattern<'tcx>,
+                            patterns: &[Pattern<'tcx>],
                             has_guard: ArmHasGuard,
                             opt_match_place: Option<(Option<&Place<'tcx>>, Span)>)
                             -> Option<SourceScope> {
         assert!(!(visibility_scope.is_some() && lint_level.is_explicit()),
                 "can't have both a visibility and a lint scope at the same time");
         let mut scope = self.source_scope;
-        self.visit_bindings(pattern, &mut |this, mutability, name, mode, var, span, ty| {
+        let num_patterns = patterns.len();
+        self.visit_bindings(&patterns[0], &mut |this, mutability, name, mode, var, span, ty| {
             if visibility_scope.is_none() {
                 visibility_scope = Some(this.new_source_scope(scope_span,
                                                            LintLevel::Inherited,
@@ -349,8 +354,9 @@ pub fn declare_bindings(&mut self,
                 scope,
             };
             let visibility_scope = visibility_scope.unwrap();
-            this.declare_binding(source_info, visibility_scope, mutability, name, mode, var,
-                                 ty, has_guard, opt_match_place.map(|(x, y)| (x.cloned(), y)));
+            this.declare_binding(source_info, visibility_scope, mutability, name, mode,
+                                 num_patterns, var, ty, has_guard,
+                                 opt_match_place.map(|(x, y)| (x.cloned(), y)));
         });
         visibility_scope
     }
@@ -453,6 +459,9 @@ pub struct Candidate<'pat, 'tcx:'pat> {
     // ...and the blocks for add false edges between candidates
     pre_binding_block: BasicBlock,
     next_candidate_pre_binding_block: BasicBlock,
+
+    // This uniquely identifies this candidate *within* the arm.
+    pat_index: usize,
 }
 
 #[derive(Clone, Debug)]
@@ -972,7 +981,8 @@ fn bind_and_guard_matched_candidate<'pat>(&mut self,
         let autoref = self.hir.tcx().all_pat_vars_are_implicit_refs_within_guards();
         if let Some(guard) = candidate.guard {
             if autoref {
-                self.bind_matched_candidate_for_guard(block, &candidate.bindings);
+                self.bind_matched_candidate_for_guard(
+                    block, candidate.pat_index, &candidate.bindings);
                 let guard_frame = GuardFrame {
                     locals: candidate.bindings.iter()
                         .map(|b| GuardFrameLocal::new(b.var_id, b.binding_mode))
@@ -1058,9 +1068,10 @@ fn bind_and_guard_matched_candidate<'pat>(&mut self,
     // and thus all code/comments assume we are in that context.
     fn bind_matched_candidate_for_guard(&mut self,
                                         block: BasicBlock,
+                                        pat_index: usize,
                                         bindings: &[Binding<'tcx>]) {
-        debug!("bind_matched_candidate_for_guard(block={:?}, bindings={:?})",
-               block, bindings);
+        debug!("bind_matched_candidate_for_guard(block={:?}, pat_index={:?}, bindings={:?})",
+               block, pat_index, bindings);
 
         // Assign each of the bindings. Since we are binding for a
         // guard expression, this will never trigger moves out of the
@@ -1099,8 +1110,9 @@ fn bind_matched_candidate_for_guard(&mut self,
                     // used by the arm body itself. This eases
                     // observing two-phase borrow restrictions.
                     let val_for_guard = self.storage_live_binding(
-                        block, binding.var_id, binding.span, ValWithinGuard);
-                    self.schedule_drop_for_binding(binding.var_id, binding.span, ValWithinGuard);
+                        block, binding.var_id, binding.span, ValWithinGuard(pat_index));
+                    self.schedule_drop_for_binding(
+                        binding.var_id, binding.span, ValWithinGuard(pat_index));
 
                     // rust-lang/rust#27282: We reuse the two-phase
                     // borrow infrastructure so that the mutable
@@ -1146,16 +1158,26 @@ fn bind_matched_candidate_for_arm_body(&mut self,
 
     /// Each binding (`ref mut var`/`ref var`/`mut var`/`var`, where
     /// the bound `var` has type `T` in the arm body) in a pattern
-    /// maps to *two* locals. The first local is a binding for
+    /// maps to `2+N` locals. The first local is a binding for
     /// occurrences of `var` in the guard, which will all have type
-    /// `&T`. The second local is a binding for occurrences of `var`
-    /// in the arm body, which will have type `T`.
+    /// `&T`. The N locals are bindings for the `T` that is referenced
+    /// by the first local; they are not used outside of the
+    /// guard. The last local is a binding for occurrences of `var` in
+    /// the arm body, which will have type `T`.
+    ///
+    /// The reason we have N locals rather than just 1 is to
+    /// accommodate rust-lang/rust#51348: If the arm has N candidate
+    /// patterns, then in general they can correspond to distinct
+    /// parts of the matched data, and we want them to be distinct
+    /// temps in order to simplify checks performed by our internal
+    /// leveraging of two-phase borrows).
     fn declare_binding(&mut self,
                        source_info: SourceInfo,
                        visibility_scope: SourceScope,
                        mutability: Mutability,
                        name: Name,
                        mode: BindingMode,
+                       num_patterns: usize,
                        var_id: NodeId,
                        var_ty: Ty<'tcx>,
                        has_guard: ArmHasGuard,
@@ -1189,7 +1211,11 @@ fn declare_binding(&mut self,
         };
         let for_arm_body = self.local_decls.push(local.clone());
         let locals = if has_guard.0 && tcx.all_pat_vars_are_implicit_refs_within_guards() {
-            let val_for_guard =  self.local_decls.push(local);
+            let mut vals_for_guard = Vec::with_capacity(num_patterns);
+            for _ in 0..num_patterns {
+                let val_for_guard_idx =  self.local_decls.push(local.clone());
+                vals_for_guard.push(val_for_guard_idx);
+            }
             let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> {
                 mutability,
                 ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty),
@@ -1200,7 +1226,7 @@ fn declare_binding(&mut self,
                 internal: false,
                 is_user_variable: Some(ClearCrossCrate::Set(BindingForm::RefForGuard)),
             });
-            LocalsForNode::Three { val_for_guard, ref_for_guard, for_arm_body }
+            LocalsForNode::ForGuard { vals_for_guard, ref_for_guard, for_arm_body }
         } else {
             LocalsForNode::One(for_arm_body)
         };
index 3ff209c872fac72f04c6763e789fbe90efa76307..afa0d28dd77180ebb6eef5e916cda5d9827d2939 100644 (file)
@@ -631,6 +631,7 @@ fn candidate_without_match_pair<'pat>(&mut self,
             bindings: candidate.bindings.clone(),
             guard: candidate.guard.clone(),
             arm_index: candidate.arm_index,
+            pat_index: candidate.pat_index,
             pre_binding_block: candidate.pre_binding_block,
             next_candidate_pre_binding_block: candidate.next_candidate_pre_binding_block,
         }
@@ -694,6 +695,7 @@ fn candidate_after_variant_switch<'pat>(&mut self,
             bindings: candidate.bindings.clone(),
             guard: candidate.guard.clone(),
             arm_index: candidate.arm_index,
+            pat_index: candidate.pat_index,
             pre_binding_block: candidate.pre_binding_block,
             next_candidate_pre_binding_block: candidate.next_candidate_pre_binding_block,
         }
index 24228389fbfbb1182d4db4ac3e3c8fa8d69a3ff1..054bd69c361b92115eb6c60dd32e67ec3cccbcd4 100644 (file)
@@ -310,8 +310,31 @@ fn var_local_id(&self, id: ast::NodeId, for_guard: ForGuard) -> Local {
 
 #[derive(Debug)]
 enum LocalsForNode {
+    /// In the usual case, a node-id for an identifier maps to at most
+    /// one Local declaration.
     One(Local),
-    Three { val_for_guard: Local, ref_for_guard: Local, for_arm_body: Local },
+
+    /// The exceptional case is identifiers in a match arm's pattern
+    /// that are referenced in a guard of that match arm. For these,
+    /// we can have `2+k` Locals, where `k` is the number of candidate
+    /// patterns (separated by `|`) in the arm.
+    ///
+    /// * `for_arm_body` is the Local used in the arm body (which is
+    ///   just like the `One` case above),
+    ///
+    /// * `ref_for_guard` is the Local used in the arm's guard (which
+    ///   is a reference to a temp that is an alias of
+    ///   `for_arm_body`).
+    ///
+    /// * `vals_for_guard` is the `k` Locals; at most one of them will
+    ///   get initialized by the arm's execution, and after it is
+    ///   initialized, `ref_for_guard` will be assigned a reference to
+    ///   it.
+    ///
+    /// There reason we have `k` Locals rather than just 1 is to
+    /// accommodate some restrictions imposed by two-phase borrows,
+    /// which apply when we have a `ref mut` pattern.
+    ForGuard { vals_for_guard: Vec<Local>, ref_for_guard: Local, for_arm_body: Local },
 }
 
 #[derive(Debug)]
@@ -350,7 +373,10 @@ struct GuardFrame {
 ///   3. the temp for use outside of guard expressions.
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 enum ForGuard {
-    ValWithinGuard,
+    /// The `usize` identifies for which candidate pattern we want the
+    /// local binding. We keep a temp per-candidate to accommodate
+    /// two-phase borrows (see `LocalsForNode` documentation).
+    ValWithinGuard(usize),
     RefWithinGuard,
     OutsideGuard,
 }
@@ -359,12 +385,15 @@ impl LocalsForNode {
     fn local_id(&self, for_guard: ForGuard) -> Local {
         match (self, for_guard) {
             (&LocalsForNode::One(local_id), ForGuard::OutsideGuard) |
-            (&LocalsForNode::Three { val_for_guard: local_id, .. }, ForGuard::ValWithinGuard) |
-            (&LocalsForNode::Three { ref_for_guard: local_id, .. }, ForGuard::RefWithinGuard) |
-            (&LocalsForNode::Three { for_arm_body: local_id, .. }, ForGuard::OutsideGuard) =>
+            (&LocalsForNode::ForGuard { ref_for_guard: local_id, .. }, ForGuard::RefWithinGuard) |
+            (&LocalsForNode::ForGuard { for_arm_body: local_id, .. }, ForGuard::OutsideGuard) =>
                 local_id,
 
-            (&LocalsForNode::One(_), ForGuard::ValWithinGuard) |
+            (&LocalsForNode::ForGuard { ref vals_for_guard, .. },
+             ForGuard::ValWithinGuard(pat_idx)) =>
+                vals_for_guard[pat_idx],
+
+            (&LocalsForNode::One(_), ForGuard::ValWithinGuard(_)) |
             (&LocalsForNode::One(_), ForGuard::RefWithinGuard) =>
                 bug!("anything with one local should never be within a guard."),
         }
@@ -740,7 +769,7 @@ fn args_and_body(&mut self,
                     }
                     _ => {
                         scope = self.declare_bindings(scope, ast_body.span,
-                                                      LintLevel::Inherited, &pattern,
+                                                      LintLevel::Inherited, &[pattern.clone()],
                                                       matches::ArmHasGuard(false),
                                                       Some((Some(&place), span)));
                         unpack!(block = self.place_into_pattern(block, pattern, &place, false));
index 382248c2d15dca3479c31234fabc94029dd15922..54730ecd75fbd0b8af86a47817fe80d5b04ab5c1 100644 (file)
@@ -14,8 +14,6 @@
 
 */
 
-#![deny(bare_trait_objects)]
-
 #![feature(slice_patterns)]
 #![feature(slice_sort_by_cached_key)]
 #![feature(from_ref)]
index d35608068a6a85e15089f4e3bfea8e733cff207d..937d01a0c5e883e6fa890abdc68f051802ed13cb 100644 (file)
@@ -41,7 +41,20 @@ fn run_pass<'a, 'tcx>(&self,
 
         let id = tcx.hir.as_local_node_id(src.def_id).unwrap();
         let param_env = tcx.param_env(src.def_id).with_reveal_all();
-        let move_data = MoveData::gather_moves(mir, tcx).unwrap();
+        let move_data = match MoveData::gather_moves(mir, tcx) {
+            Ok(move_data) => move_data,
+            Err((move_data, _move_errors)) => {
+                // The only way we should be allowing any move_errors
+                // in here is if we are in the migration path for the
+                // NLL-based MIR-borrowck.
+                //
+                // If we are in the migration path, we have already
+                // reported these errors as warnings to the user. So
+                // we will just ignore them here.
+                assert!(tcx.migrate_borrowck());
+                move_data
+            }
+        };
         let elaborate_patch = {
             let mir = &*mir;
             let env = MoveDataParamEnv {
index 7bd1e98f85dc2fa553b1ebd0e3510e9cc3e65462..0c78fd74a234ee01091ae813c400b30afc8c575f 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![sanitizer_runtime]
 #![feature(alloc_system)]
 #![feature(sanitizer_runtime)]
index 15d7c0fdaa338673d7877c914ef898bf9ccb66f9..41f1e7829658ab097353ca1a3fa7b26061d9226b 100644 (file)
@@ -14,8 +14,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/")]
index 92e83fd70fa3a4dc79021183affe22e8114ba04e..b57debdd99486bda802323fe72cbc624d136d530 100644 (file)
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 #![allow(bad_style)]
-#![deny(bare_trait_objects)]
 
 pub struct Intrinsic {
     pub inputs: &'static [&'static Type],
index b2c492f204f331c27863c025bdb96e69f0350750..348aa6a7cef4c7678c85c7e43dde9ca7ea9aef43 100644 (file)
@@ -60,8 +60,6 @@
 //! See the [`plugin` feature](../unstable-book/language-features/plugin.html) of
 //! the Unstable Book for more examples.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/")]
index 7b13c98b31ddf4ba31438711da3000c36f488e6a..405952065dacb6f9401254a327ace54e86cd2765 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/")]
index 765016fdc4a7470c3d9b878c1e993c8eadb3fae5..8130c4e83265604126d22d00f05c761fe9e70d97 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
index c84f194f0232a7b3fd81944773af6806910ffbe3..a250d4a3598c51f07c95035d24f96f6e4524a7cb 100644 (file)
@@ -13,7 +13,6 @@
        html_root_url = "https://doc.rust-lang.org/nightly/")]
 #![feature(custom_attribute)]
 #![allow(unused_attributes)]
-#![deny(bare_trait_objects)]
 
 #![recursion_limit="256"]
 
index e611d26da56def22e2efcd149aaf4dd10b4d2e42..8f4911574398ba84d2f6874f334e371d8e93666f 100644 (file)
@@ -21,8 +21,6 @@
 //! one that doesn't; the one that doesn't might get decent parallel
 //! build speedups.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
diff --git a/src/librustc_target/spec/aarch64_fuchsia.rs b/src/librustc_target/spec/aarch64_fuchsia.rs
new file mode 100644 (file)
index 0000000..28baf6f
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::fuchsia_base::opts();
+    base.max_atomic_width = Some(128);
+
+    Ok(Target {
+        llvm_target: "aarch64-fuchsia".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "64".to_string(),
+        target_c_int_width: "32".to_string(),
+        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
+        arch: "aarch64".to_string(),
+        target_os: "fuchsia".to_string(),
+        target_env: "".to_string(),
+        target_vendor: "".to_string(),
+        linker_flavor: LinkerFlavor::Gcc,
+        options: TargetOptions {
+            abi_blacklist: super::arm_base::abi_blacklist(),
+            .. base
+        },
+    })
+}
diff --git a/src/librustc_target/spec/aarch64_unknown_fuchsia.rs b/src/librustc_target/spec/aarch64_unknown_fuchsia.rs
deleted file mode 100644 (file)
index 4da6724..0000000
+++ /dev/null
@@ -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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
-
-pub fn target() -> TargetResult {
-    let mut base = super::fuchsia_base::opts();
-    base.max_atomic_width = Some(128);
-
-    Ok(Target {
-        llvm_target: "aarch64-unknown-fuchsia".to_string(),
-        target_endian: "little".to_string(),
-        target_pointer_width: "64".to_string(),
-        target_c_int_width: "32".to_string(),
-        data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
-        arch: "aarch64".to_string(),
-        target_os: "fuchsia".to_string(),
-        target_env: "".to_string(),
-        target_vendor: "unknown".to_string(),
-        linker_flavor: LinkerFlavor::Gcc,
-        options: TargetOptions {
-            abi_blacklist: super::arm_base::abi_blacklist(),
-            .. base
-        },
-    })
-}
index 19a66b693f25614101e128818d5be07524a2869d..b593b83532614b4801a0f9ecc8755aafb36d0588 100644 (file)
@@ -33,7 +33,7 @@ pub fn opts() -> TargetOptions {
         executables: true,
         target_family: Some("unix".to_string()),
         linker_is_gnu: true,
-        has_rpath: true,
+        has_rpath: false,
         pre_link_args: args,
         position_independent_executables: true,
         has_elf_tls: true,
index 9ac6e9835f06fcb4e5acb36c20d957aa3b99b133..c5d21cdc46adb3fe589987b48a0cbe82ed358154 100644 (file)
@@ -332,8 +332,8 @@ fn $module() {
     ("x86_64-apple-darwin", x86_64_apple_darwin),
     ("i686-apple-darwin", i686_apple_darwin),
 
-    ("aarch64-unknown-fuchsia", aarch64_unknown_fuchsia),
-    ("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia),
+    ("aarch64-fuchsia", aarch64_fuchsia),
+    ("x86_64-fuchsia", x86_64_fuchsia),
 
     ("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc),
 
diff --git a/src/librustc_target/spec/x86_64_fuchsia.rs b/src/librustc_target/spec/x86_64_fuchsia.rs
new file mode 100644 (file)
index 0000000..e8fa179
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use spec::{LinkerFlavor, Target, TargetResult};
+
+pub fn target() -> TargetResult {
+    let mut base = super::fuchsia_base::opts();
+    base.cpu = "x86-64".to_string();
+    base.max_atomic_width = Some(64);
+    base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
+    base.stack_probes = true;
+
+    Ok(Target {
+        llvm_target: "x86_64-fuchsia".to_string(),
+        target_endian: "little".to_string(),
+        target_pointer_width: "64".to_string(),
+        target_c_int_width: "32".to_string(),
+        data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
+        arch: "x86_64".to_string(),
+        target_os: "fuchsia".to_string(),
+        target_env: "".to_string(),
+        target_vendor: "".to_string(),
+        linker_flavor: LinkerFlavor::Gcc,
+        options: base,
+    })
+}
diff --git a/src/librustc_target/spec/x86_64_unknown_fuchsia.rs b/src/librustc_target/spec/x86_64_unknown_fuchsia.rs
deleted file mode 100644 (file)
index a510ec8..0000000
+++ /dev/null
@@ -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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use spec::{LinkerFlavor, Target, TargetResult};
-
-pub fn target() -> TargetResult {
-    let mut base = super::fuchsia_base::opts();
-    base.cpu = "x86-64".to_string();
-    base.max_atomic_width = Some(64);
-    base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string());
-    base.stack_probes = true;
-
-    Ok(Target {
-        llvm_target: "x86_64-unknown-fuchsia".to_string(),
-        target_endian: "little".to_string(),
-        target_pointer_width: "64".to_string(),
-        target_c_int_width: "32".to_string(),
-        data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
-        arch: "x86_64".to_string(),
-        target_os: "fuchsia".to_string(),
-        target_env: "".to_string(),
-        target_vendor: "unknown".to_string(),
-        linker_flavor: LinkerFlavor::Gcc,
-        options: base,
-    })
-}
index 2a4cacb5623ecc6b7db5b94404fdff3bb8cf08da..d17cf35f1816ae2eba259d647d775c7c70df132d 100644 (file)
@@ -11,8 +11,6 @@
 //! New recursive solver modeled on Chalk's recursive solver. Most of
 //! the guts are broken up into modules; see the comments in those modules.
 
-#![deny(bare_trait_objects)]
-
 #![feature(crate_in_paths)]
 #![feature(crate_visibility_modifier)]
 #![feature(extern_prelude)]
index 7bd1e98f85dc2fa553b1ebd0e3510e9cc3e65462..0c78fd74a234ee01091ae813c400b30afc8c575f 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![sanitizer_runtime]
 #![feature(alloc_system)]
 #![feature(sanitizer_runtime)]
index 220dd122b26795b6c7516fb11c3e8a71f800b070..55aa38d942efb64abbcc12b699238be66d41ec17 100644 (file)
@@ -319,6 +319,17 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                             E0053,
                                             "method `{}` has an incompatible type for trait",
                                             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.codemap().span_to_snippet(trait_err_span) {
+                        diag.span_suggestion(
+                            impl_err_span,
+                            "consider change the type to match the mutability in trait",
+                            format!("{}", trait_err_str),
+                        );
+                    }
+                }
+            }
 
             infcx.note_type_err(&mut diag,
                                 &cause,
index 03ecb945cbd3c9497f0f71182ba58ada0d49d37d..38743cc9cf65f4d8bfdbaa529567a3a0cae4d02c 100644 (file)
@@ -211,8 +211,7 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 }
             }
             ty::AssociatedKind::Existential => {
-                // FIXME(oli-obk) implement existential types in trait impls
-                unimplemented!()
+                // do nothing, existential types check themselves
             }
         }
 
index 60f8928255174a361515d3ac83917a133ca73a09..cd84a61bb2c3551b04375c128b7e46d2e95db5cd 100644 (file)
@@ -1046,12 +1046,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                     tcx.mk_fn_def(def_id, substs)
                 }
                 ImplItemKind::Const(ref ty, _) => icx.to_ty(ty),
-                ImplItemKind::Existential(ref _bounds) => {
+                ImplItemKind::Existential(_) => {
                     if tcx.impl_trait_ref(tcx.hir.get_parent_did(node_id)).is_none() {
                         report_assoc_ty_on_inherent_impl(tcx, item.span);
                     }
-                    // FIXME(oli-obk) implement existential types in trait impls
-                    unimplemented!()
+
+                    find_existential_constraints(tcx, def_id)
                 }
                 ImplItemKind::Type(ref ty) => {
                     if tcx.impl_trait_ref(tcx.hir.get_parent_did(node_id)).is_none() {
@@ -1186,8 +1186,10 @@ struct ConstraintLocator<'a, 'tcx: 'a> {
     }
     impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> {
         fn check(&mut self, def_id: DefId) {
+            trace!("checking {:?}", def_id);
             // don't try to check items that cannot possibly constrain the type
             if !self.tcx.has_typeck_tables(def_id) {
+                trace!("no typeck tables for {:?}", def_id);
                 return;
             }
             let ty = self
@@ -1244,9 +1246,11 @@ fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
     let mut locator = ConstraintLocator { def_id, tcx, found: None };
     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 {
+        trace!("parent: {:?}", tcx.hir.get(parent));
         match tcx.hir.get(parent) {
             NodeItem(ref it) => intravisit::walk_item(&mut locator, it),
             NodeImplItem(ref it) => intravisit::walk_impl_item(&mut locator, it),
@@ -1485,7 +1489,23 @@ fn explicit_predicates_of<'a, 'tcx>(
             &item.generics
         }
 
-        NodeImplItem(item) => &item.generics,
+        NodeImplItem(item) => match item.node {
+            ImplItemKind::Existential(ref bounds) => {
+                let substs = Substs::identity_for_item(tcx, def_id);
+                let anon_ty = tcx.mk_anon(def_id, substs);
+
+                // Collect the bounds, i.e. the `A+B+'c` in `impl A+B+'c`.
+                let bounds = compute_bounds(&icx,
+                                            anon_ty,
+                                            bounds,
+                                            SizedByDefault::Yes,
+                                            tcx.def_span(def_id));
+
+                predicates.extend(bounds.predicates(tcx, anon_ty));
+                &item.generics
+            },
+            _ => &item.generics,
+        }
 
         NodeItem(item) => {
             match item.node {
index e343fb1a57b1f294b0f3f512b4ccd41761ee8d4b..6bf1ec8f697a25f8be88738f6ddfa60ab5a1622d 100644 (file)
@@ -70,7 +70,6 @@
       html_root_url = "https://doc.rust-lang.org/nightly/")]
 
 #![allow(non_camel_case_types)]
-#![deny(bare_trait_objects)]
 
 #![feature(box_patterns)]
 #![feature(box_syntax)]
index 98684b27973bc660bc351bfc9b2feff15652ceb9..c601f138d0a21fa556e0d71eb7fb9f79218ebd15 100644 (file)
@@ -375,7 +375,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 
         let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate)
                                    .map(|id| self.def_id >= *id).unwrap_or(false));
-        let def_id: &fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
+        let def_id: &dyn fmt::Debug = if fake { &"**FAKE**" } else { &self.def_id };
 
         fmt.debug_struct("Item")
             .field("source", &self.source)
index 6e1b45895474a5848ea3977b386c08269f84c6be..4b8dbaf421138f4dd65fcb18f22b6178caaf508f 100644 (file)
@@ -55,7 +55,7 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> {
     /// The stack of module NodeIds up till this point
     pub mod_ids: RefCell<Vec<NodeId>>,
     pub crate_name: Option<String>,
-    pub cstore: Rc<CrateStore>,
+    pub cstore: Rc<dyn CrateStore>,
     pub populated_all_crate_impls: Cell<bool>,
     // 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
index 5939d5341e324a5cc28f3d222b021c1a2607eacf..6cf9b143373a8ad26bf09a2f4b07771b8796ff67 100644 (file)
@@ -395,7 +395,7 @@ pub fn rustdoc_class(self) -> &'static str {
 
 fn write_header(class: Option<&str>,
                 id: Option<&str>,
-                out: &mut Write)
+                out: &mut dyn Write)
                 -> io::Result<()> {
     write!(out, "<pre ")?;
     if let Some(id) = id {
@@ -404,6 +404,6 @@ fn write_header(class: Option<&str>,
     write!(out, "class=\"rust {}\">\n", class.unwrap_or(""))
 }
 
-fn write_footer(out: &mut Write) -> io::Result<()> {
+fn write_footer(out: &mut dyn Write) -> io::Result<()> {
     write!(out, "</pre>\n")
 }
index 5e93b20ea17fdb978b06693c5c38b4fb51c69bac..af7c0a04215c12f6356698aaef3029192f965ab5 100644 (file)
@@ -32,7 +32,7 @@ pub struct Page<'a> {
 }
 
 pub fn render<T: fmt::Display, S: fmt::Display>(
-    dst: &mut io::Write, layout: &Layout, page: &Page, sidebar: &S, t: &T,
+    dst: &mut dyn io::Write, layout: &Layout, page: &Page, sidebar: &S, t: &T,
     css_file_extension: bool, themes: &[PathBuf])
     -> io::Result<()>
 {
@@ -194,7 +194,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
     )
 }
 
-pub fn redirect(dst: &mut io::Write, url: &str) -> io::Result<()> {
+pub fn redirect(dst: &mut dyn io::Write, url: &str) -> io::Result<()> {
     // <script> triggers a redirect before refresh, so this is fine.
     write!(dst,
 r##"<!DOCTYPE html>
index ade33c8dd7d197c7bbb6106aa402f5222e40a415..f137f4acf448655428628abd07ec23b06c222a2d 100644 (file)
@@ -1822,7 +1822,7 @@ fn krate(self, mut krate: clean::Crate) -> Result<(), Error> {
     }
 
     fn render_item(&self,
-                   writer: &mut io::Write,
+                   writer: &mut dyn io::Write,
                    it: &clean::Item,
                    pushname: bool)
                    -> io::Result<()> {
index eb980a7369bf27ac2e62370c268d6f6072fcf017..2966b9e9819b4771724bf3731f6fd9fa7194ad37 100644 (file)
@@ -249,7 +249,7 @@ fn write(&mut self, data: &[u8]) -> io::Result<usize> {
         }
         fn flush(&mut self) -> io::Result<()> { Ok(()) }
     }
-    struct Bomb(Arc<Mutex<Vec<u8>>>, Box<Write+Send>);
+    struct Bomb(Arc<Mutex<Vec<u8>>>, Box<dyn Write+Send>);
     impl Drop for Bomb {
         fn drop(&mut self) {
             let _ = self.1.write_all(&self.0.lock().unwrap());
index 7c1bb69434d5f0110030d529a6cdff9b939bcb3c..a5f4b32b329e7c22a51c791035a9cb05d168076d 100644 (file)
@@ -14,8 +14,6 @@
 Core encoding and decoding interfaces.
 */
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/",
index 1958915602f839b3492c3984acbe06f59ba84629..29534696abc5be232de994c97448fe71c6e3b398 100644 (file)
@@ -138,7 +138,7 @@ fn description(&self) -> &str {
     /// }
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
-    fn cause(&self) -> Option<&Error> { None }
+    fn cause(&self) -> Option<&dyn Error> { None }
 
     /// Get the `TypeId` of `self`
     #[doc(hidden)]
@@ -151,22 +151,22 @@ fn type_id(&self) -> TypeId where Self: 'static {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, E: Error + 'a> From<E> for Box<Error + 'a> {
-    fn from(err: E) -> Box<Error + 'a> {
+impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
+    fn from(err: E) -> Box<dyn Error + 'a> {
         Box::new(err)
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<Error + Send + Sync + 'a> {
-    fn from(err: E) -> Box<Error + Send + Sync + 'a> {
+impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync + 'a> {
+    fn from(err: E) -> Box<dyn Error + Send + Sync + 'a> {
         Box::new(err)
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl From<String> for Box<Error + Send + Sync> {
-    fn from(err: String) -> Box<Error + Send + Sync> {
+impl From<String> for Box<dyn Error + Send + Sync> {
+    fn from(err: String) -> Box<dyn Error + Send + Sync> {
         #[derive(Debug)]
         struct StringError(String);
 
@@ -185,38 +185,38 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[stable(feature = "string_box_error", since = "1.6.0")]
-impl From<String> for Box<Error> {
-    fn from(str_err: String) -> Box<Error> {
-        let err1: Box<Error + Send + Sync> = From::from(str_err);
-        let err2: Box<Error> = err1;
+impl From<String> for Box<dyn Error> {
+    fn from(str_err: String) -> Box<dyn Error> {
+        let err1: Box<dyn Error + Send + Sync> = From::from(str_err);
+        let err2: Box<dyn Error> = err1;
         err2
     }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a> {
-    fn from(err: &'b str) -> Box<Error + Send + Sync + 'a> {
+impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
+    fn from(err: &'b str) -> Box<dyn Error + Send + Sync + 'a> {
         From::from(String::from(err))
     }
 }
 
 #[stable(feature = "string_box_error", since = "1.6.0")]
-impl<'a> From<&'a str> for Box<Error> {
-    fn from(err: &'a str) -> Box<Error> {
+impl<'a> From<&'a str> for Box<dyn Error> {
+    fn from(err: &'a str) -> Box<dyn Error> {
         From::from(String::from(err))
     }
 }
 
 #[stable(feature = "cow_box_error", since = "1.22.0")]
-impl<'a, 'b> From<Cow<'b, str>> for Box<Error + Send + Sync + 'a> {
-    fn from(err: Cow<'b, str>) -> Box<Error + Send + Sync + 'a> {
+impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
+    fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a> {
         From::from(String::from(err))
     }
 }
 
 #[stable(feature = "cow_box_error", since = "1.22.0")]
-impl<'a> From<Cow<'a, str>> for Box<Error> {
-    fn from(err: Cow<'a, str>) -> Box<Error> {
+impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
+    fn from(err: Cow<'a, str>) -> Box<dyn Error> {
         From::from(String::from(err))
     }
 }
@@ -327,7 +327,7 @@ fn description(&self) -> &str {
         Error::description(&**self)
     }
 
-    fn cause(&self) -> Option<&Error> {
+    fn cause(&self) -> Option<&dyn Error> {
         Error::cause(&**self)
     }
 }
@@ -368,7 +368,7 @@ fn description(&self) -> &str {
 }
 
 // copied from any.rs
-impl Error + 'static {
+impl dyn Error + 'static {
     /// Returns true if the boxed type is the same as `T`
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
@@ -390,7 +390,7 @@ pub fn is<T: Error + 'static>(&self) -> bool {
     pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
         if self.is::<T>() {
             unsafe {
-                Some(&*(self as *const Error as *const T))
+                Some(&*(self as *const dyn Error as *const T))
             }
         } else {
             None
@@ -404,7 +404,7 @@ pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
     pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
         if self.is::<T>() {
             unsafe {
-                Some(&mut *(self as *mut Error as *mut T))
+                Some(&mut *(self as *mut dyn Error as *mut T))
             }
         } else {
             None
@@ -412,60 +412,60 @@ pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
     }
 }
 
-impl Error + 'static + Send {
+impl dyn Error + 'static + Send {
     /// Forwards to the method defined on the type `Any`.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
     pub fn is<T: Error + 'static>(&self) -> bool {
-        <Error + 'static>::is::<T>(self)
+        <dyn Error + 'static>::is::<T>(self)
     }
 
     /// Forwards to the method defined on the type `Any`.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
     pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
-        <Error + 'static>::downcast_ref::<T>(self)
+        <dyn Error + 'static>::downcast_ref::<T>(self)
     }
 
     /// Forwards to the method defined on the type `Any`.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
     pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
-        <Error + 'static>::downcast_mut::<T>(self)
+        <dyn Error + 'static>::downcast_mut::<T>(self)
     }
 }
 
-impl Error + 'static + Send + Sync {
+impl dyn Error + 'static + Send + Sync {
     /// Forwards to the method defined on the type `Any`.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
     pub fn is<T: Error + 'static>(&self) -> bool {
-        <Error + 'static>::is::<T>(self)
+        <dyn Error + 'static>::is::<T>(self)
     }
 
     /// Forwards to the method defined on the type `Any`.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
     pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
-        <Error + 'static>::downcast_ref::<T>(self)
+        <dyn Error + 'static>::downcast_ref::<T>(self)
     }
 
     /// Forwards to the method defined on the type `Any`.
     #[stable(feature = "error_downcast", since = "1.3.0")]
     #[inline]
     pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
-        <Error + 'static>::downcast_mut::<T>(self)
+        <dyn Error + 'static>::downcast_mut::<T>(self)
     }
 }
 
-impl Error {
+impl dyn Error {
     #[inline]
     #[stable(feature = "error_downcast", since = "1.3.0")]
     /// Attempt to downcast the box to a concrete type.
-    pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Error>> {
+    pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<dyn Error>> {
         if self.is::<T>() {
             unsafe {
-                let raw: *mut Error = Box::into_raw(self);
+                let raw: *mut dyn Error = Box::into_raw(self);
                 Ok(Box::from_raw(raw as *mut T))
             }
         } else {
@@ -474,30 +474,30 @@ pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Error
     }
 }
 
-impl Error + Send {
+impl dyn Error + Send {
     #[inline]
     #[stable(feature = "error_downcast", since = "1.3.0")]
     /// Attempt to downcast the box to a concrete type.
     pub fn downcast<T: Error + 'static>(self: Box<Self>)
-                                        -> Result<Box<T>, Box<Error + Send>> {
-        let err: Box<Error> = self;
-        <Error>::downcast(err).map_err(|s| unsafe {
+                                        -> Result<Box<T>, Box<dyn Error + Send>> {
+        let err: Box<dyn Error> = self;
+        <dyn Error>::downcast(err).map_err(|s| unsafe {
             // reapply the Send marker
-            transmute::<Box<Error>, Box<Error + Send>>(s)
+            transmute::<Box<dyn Error>, Box<dyn Error + Send>>(s)
         })
     }
 }
 
-impl Error + Send + Sync {
+impl dyn Error + Send + Sync {
     #[inline]
     #[stable(feature = "error_downcast", since = "1.3.0")]
     /// Attempt to downcast the box to a concrete type.
     pub fn downcast<T: Error + 'static>(self: Box<Self>)
                                         -> Result<Box<T>, Box<Self>> {
-        let err: Box<Error> = self;
-        <Error>::downcast(err).map_err(|s| unsafe {
+        let err: Box<dyn Error> = self;
+        <dyn Error>::downcast(err).map_err(|s| unsafe {
             // reapply the Send+Sync marker
-            transmute::<Box<Error>, Box<Error + Send + Sync>>(s)
+            transmute::<Box<dyn Error>, Box<dyn Error + Send + Sync>>(s)
         })
     }
 }
@@ -533,13 +533,13 @@ fn description(&self) -> &str { "A-desc" }
     #[test]
     fn downcasting() {
         let mut a = A;
-        let a = &mut a as &mut (Error + 'static);
+        let a = &mut a as &mut (dyn Error + 'static);
         assert_eq!(a.downcast_ref::<A>(), Some(&A));
         assert_eq!(a.downcast_ref::<B>(), None);
         assert_eq!(a.downcast_mut::<A>(), Some(&mut A));
         assert_eq!(a.downcast_mut::<B>(), None);
 
-        let a: Box<Error> = Box::new(A);
+        let a: Box<dyn Error> = Box::new(A);
         match a.downcast::<B>() {
             Ok(..) => panic!("expected error"),
             Err(e) => assert_eq!(*e.downcast::<A>().unwrap(), A),
index b816f4b7850efb17aaea0f3e4b0bcca774a838a4..754e2bbc4122b7f127b679fbaf3e5bda488ac6a3 100644 (file)
@@ -891,7 +891,7 @@ fn description(&self) -> &str {
         "C string contained non-utf8 bytes"
     }
 
-    fn cause(&self) -> Option<&Error> {
+    fn cause(&self) -> Option<&dyn Error> {
         Some(&self.error)
     }
 }
index bdd675e6e2b851d8f581190902a913ac140ce26b..02a3ce8b9c4d475a0dcdb366fcdcd44a9344521b 100644 (file)
@@ -83,7 +83,7 @@ enum Repr {
 #[derive(Debug)]
 struct Custom {
     kind: ErrorKind,
-    error: Box<error::Error+Send+Sync>,
+    error: Box<dyn error::Error+Send+Sync>,
 }
 
 /// A list specifying general categories of I/O error.
@@ -250,12 +250,12 @@ impl Error {
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn new<E>(kind: ErrorKind, error: E) -> Error
-        where E: Into<Box<error::Error+Send+Sync>>
+        where E: Into<Box<dyn error::Error+Send+Sync>>
     {
         Self::_new(kind, error.into())
     }
 
-    fn _new(kind: ErrorKind, error: Box<error::Error+Send+Sync>) -> Error {
+    fn _new(kind: ErrorKind, error: Box<dyn error::Error+Send+Sync>) -> Error {
         Error {
             repr: Repr::Custom(Box::new(Custom {
                 kind,
@@ -373,7 +373,7 @@ pub fn raw_os_error(&self) -> Option<i32> {
     /// }
     /// ```
     #[stable(feature = "io_error_inner", since = "1.3.0")]
-    pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> {
+    pub fn get_ref(&self) -> Option<&(dyn error::Error+Send+Sync+'static)> {
         match self.repr {
             Repr::Os(..) => None,
             Repr::Simple(..) => None,
@@ -444,7 +444,7 @@ pub fn get_ref(&self) -> Option<&(error::Error+Send+Sync+'static)> {
     /// }
     /// ```
     #[stable(feature = "io_error_inner", since = "1.3.0")]
-    pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> {
+    pub fn get_mut(&mut self) -> Option<&mut (dyn error::Error+Send+Sync+'static)> {
         match self.repr {
             Repr::Os(..) => None,
             Repr::Simple(..) => None,
@@ -478,7 +478,7 @@ pub fn get_mut(&mut self) -> Option<&mut (error::Error+Send+Sync+'static)> {
     /// }
     /// ```
     #[stable(feature = "io_error_inner", since = "1.3.0")]
-    pub fn into_inner(self) -> Option<Box<error::Error+Send+Sync>> {
+    pub fn into_inner(self) -> Option<Box<dyn error::Error+Send+Sync>> {
         match self.repr {
             Repr::Os(..) => None,
             Repr::Simple(..) => None,
@@ -551,7 +551,7 @@ fn description(&self) -> &str {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         match self.repr {
             Repr::Os(..) => None,
             Repr::Simple(..) => None,
index 2b4644bd013f2aa6d9a8911a7296041965999eff..8530487484827e5d8d404151a26bcb769eecde4c 100644 (file)
@@ -1972,7 +1972,7 @@ fn consume(&mut self, amt: usize) {
     }
 }
 
-fn read_one_byte(reader: &mut Read) -> Option<Result<u8>> {
+fn read_one_byte(reader: &mut dyn Read) -> Option<Result<u8>> {
     let mut buf = [0];
     loop {
         return match reader.read(&mut buf) {
@@ -2081,7 +2081,7 @@ fn description(&self) -> &str {
             CharsError::Other(ref e) => std_error::Error::description(e),
         }
     }
-    fn cause(&self) -> Option<&std_error::Error> {
+    fn cause(&self) -> Option<&dyn std_error::Error> {
         match *self {
             CharsError::NotUtf8 => None,
             CharsError::Other(ref e) => e.cause(),
index fce85a200ba2e98b39784f7279ffa7b5e3ea5ce1..fffe8fc559b8192b63c12f7208d23bac9dbf0a89 100644 (file)
@@ -21,7 +21,7 @@
 
 /// Stdout used by print! and println! macros
 thread_local! {
-    static LOCAL_STDOUT: RefCell<Option<Box<Write + Send>>> = {
+    static LOCAL_STDOUT: RefCell<Option<Box<dyn Write + Send>>> = {
         RefCell::new(None)
     }
 }
@@ -624,7 +624,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                      with a more general mechanism",
            issue = "0")]
 #[doc(hidden)]
-pub fn set_panic(sink: Option<Box<Write + Send>>) -> Option<Box<Write + Send>> {
+pub fn set_panic(sink: Option<Box<dyn Write + Send>>) -> Option<Box<dyn Write + Send>> {
     use panicking::LOCAL_STDERR;
     use mem;
     LOCAL_STDERR.with(move |slot| {
@@ -648,7 +648,7 @@ pub fn set_panic(sink: Option<Box<Write + Send>>) -> Option<Box<Write + Send>> {
                      with a more general mechanism",
            issue = "0")]
 #[doc(hidden)]
-pub fn set_print(sink: Option<Box<Write + Send>>) -> Option<Box<Write + Send>> {
+pub fn set_print(sink: Option<Box<dyn Write + Send>>) -> Option<Box<dyn Write + Send>> {
     use mem;
     LOCAL_STDOUT.with(move |slot| {
         mem::replace(&mut *slot.borrow_mut(), sink)
@@ -670,7 +670,7 @@ pub fn set_print(sink: Option<Box<Write + Send>>) -> Option<Box<Write + Send>> {
 /// However, if the actual I/O causes an error, this function does panic.
 fn print_to<T>(
     args: fmt::Arguments,
-    local_s: &'static LocalKey<RefCell<Option<Box<Write+Send>>>>,
+    local_s: &'static LocalKey<RefCell<Option<Box<dyn Write+Send>>>>,
     global_s: fn() -> T,
     label: &str,
 )
index 195310a26fed643f05ec6e9abd5eb370cf90261d..33f741dbc38f22716aa2762b959be5108c9d7c4a 100644 (file)
@@ -223,7 +223,7 @@ fn copy_copies() {
         assert_eq!(copy(&mut r, &mut w).unwrap(), 4);
 
         let mut r = repeat(0).take(1 << 17);
-        assert_eq!(copy(&mut r as &mut Read, &mut w as &mut Write).unwrap(), 1 << 17);
+        assert_eq!(copy(&mut r as &mut dyn Read, &mut w as &mut dyn Write).unwrap(), 1 << 17);
     }
 
     #[test]
index 008c5da171ffc663e68a1afe06701b71b40b3f23..cf3e5354a3188829309008437541ee13822178a5 100644 (file)
@@ -58,7 +58,7 @@ fn read_till_eof<T, F>(&mut self, cb: F) -> Option<T> where
     }
 
     // Return result of first successful parser
-    fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T> + 'static>])
+    fn read_or<T>(&mut self, parsers: &mut [Box<dyn FnMut(&mut Parser) -> Option<T> + 'static>])
                -> Option<T> {
         for pf in parsers {
             if let Some(r) = self.read_atomically(|p: &mut Parser| pf(p)) {
index 6b4bbdddf32df8e63fb40d2da12d986904935bb8..75c7a3d92809440c48817897331a5909bbf39b45 100644 (file)
@@ -927,7 +927,7 @@ mod tests {
     use time::{Instant, Duration};
     use thread;
 
-    fn each_ip(f: &mut FnMut(SocketAddr)) {
+    fn each_ip(f: &mut dyn FnMut(SocketAddr)) {
         f(next_test_ip4());
         f(next_test_ip6());
     }
index d25e29999cb68c2457e51ffbdc51173f3c4247cf..0ebe3284b4f0a9de5a8c33d653c77b78341f0f8d 100644 (file)
@@ -826,7 +826,7 @@ mod tests {
     use time::{Instant, Duration};
     use thread;
 
-    fn each_ip(f: &mut FnMut(SocketAddr, SocketAddr)) {
+    fn each_ip(f: &mut dyn FnMut(SocketAddr, SocketAddr)) {
         f(next_test_ip4(), next_test_ip4());
         f(next_test_ip6(), next_test_ip6());
     }
index 451420ae88ad8179f1ec1f37efaad1a458bf13fb..b8c1c4f9e68e7602ad5ab3b78679abf3f84e7988 100644 (file)
@@ -421,6 +421,6 @@ pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
 /// }
 /// ```
 #[stable(feature = "resume_unwind", since = "1.9.0")]
-pub fn resume_unwind(payload: Box<Any + Send>) -> ! {
+pub fn resume_unwind(payload: Box<dyn Any + Send>) -> ! {
     panicking::update_count_then_panic(payload)
 }
index 46b6cf60705c1c926d1420d110f2ecd6ca4cfc22..283fd36af41ff4976ca69b7896856a157492077b 100644 (file)
@@ -36,7 +36,7 @@
 use thread;
 
 thread_local! {
-    pub static LOCAL_STDERR: RefCell<Option<Box<Write + Send>>> = {
+    pub static LOCAL_STDERR: RefCell<Option<Box<dyn Write + Send>>> = {
         RefCell::new(None)
     }
 }
@@ -64,7 +64,7 @@ fn __rust_maybe_catch_panic(f: fn(*mut u8),
 #[derive(Copy, Clone)]
 enum Hook {
     Default,
-    Custom(*mut (Fn(&PanicInfo) + 'static + Sync + Send)),
+    Custom(*mut (dyn Fn(&PanicInfo) + 'static + Sync + Send)),
 }
 
 static HOOK_LOCK: RWLock = RWLock::new();
@@ -104,7 +104,7 @@ enum Hook {
 /// panic!("Normal panic");
 /// ```
 #[stable(feature = "panic_hooks", since = "1.10.0")]
-pub fn set_hook(hook: Box<Fn(&PanicInfo) + 'static + Sync + Send>) {
+pub fn set_hook(hook: Box<dyn Fn(&PanicInfo) + 'static + Sync + Send>) {
     if thread::panicking() {
         panic!("cannot modify the panic hook from a panicking thread");
     }
@@ -149,7 +149,7 @@ pub fn set_hook(hook: Box<Fn(&PanicInfo) + 'static + Sync + Send>) {
 /// panic!("Normal panic");
 /// ```
 #[stable(feature = "panic_hooks", since = "1.10.0")]
-pub fn take_hook() -> Box<Fn(&PanicInfo) + 'static + Sync + Send> {
+pub fn take_hook() -> Box<dyn Fn(&PanicInfo) + 'static + Sync + Send> {
     if thread::panicking() {
         panic!("cannot modify the panic hook from a panicking thread");
     }
@@ -197,7 +197,7 @@ fn default_hook(info: &PanicInfo) {
     let thread = thread_info::current_thread();
     let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>");
 
-    let write = |err: &mut ::io::Write| {
+    let write = |err: &mut dyn (::io::Write)| {
         let _ = writeln!(err, "thread '{}' panicked at '{}', {}",
                          name, msg, location);
 
@@ -248,7 +248,7 @@ pub fn update_panic_count(amt: isize) -> usize {
 pub use realstd::rt::update_panic_count;
 
 /// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
-pub unsafe fn try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<Any + Send>> {
+pub unsafe fn try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
     #[allow(unions_with_drop_fields)]
     union Data<F, R> {
         f: F,
@@ -369,12 +369,12 @@ fn fill(&mut self) -> &mut String {
     }
 
     unsafe impl<'a> BoxMeUp for PanicPayload<'a> {
-        fn box_me_up(&mut self) -> *mut (Any + Send) {
+        fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
             let contents = mem::replace(self.fill(), String::new());
             Box::into_raw(Box::new(contents))
         }
 
-        fn get(&mut self) -> &(Any + Send) {
+        fn get(&mut self) -> &(dyn Any + Send) {
             self.fill()
         }
     }
@@ -419,15 +419,15 @@ fn new(inner: A) -> PanicPayload<A> {
     }
 
     unsafe impl<A: Send + 'static> BoxMeUp for PanicPayload<A> {
-        fn box_me_up(&mut self) -> *mut (Any + Send) {
+        fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
             let data = match self.inner.take() {
-                Some(a) => Box::new(a) as Box<Any + Send>,
+                Some(a) => Box::new(a) as Box<dyn Any + Send>,
                 None => Box::new(()),
             };
             Box::into_raw(data)
         }
 
-        fn get(&mut self) -> &(Any + Send) {
+        fn get(&mut self) -> &(dyn Any + Send) {
             match self.inner {
                 Some(ref a) => a,
                 None => &(),
@@ -441,7 +441,7 @@ fn get(&mut self) -> &(Any + Send) {
 /// Executes the primary logic for a panic, including checking for recursive
 /// panics, panic hooks, and finally dispatching to the panic runtime to either
 /// abort or unwind.
-fn rust_panic_with_hook(payload: &mut BoxMeUp,
+fn rust_panic_with_hook(payload: &mut dyn BoxMeUp,
                         message: Option<&fmt::Arguments>,
                         file_line_col: &(&str, u32, u32)) -> ! {
     let (file, line, col) = *file_line_col;
@@ -496,17 +496,17 @@ fn rust_panic_with_hook(payload: &mut BoxMeUp,
 }
 
 /// Shim around rust_panic. Called by resume_unwind.
-pub fn update_count_then_panic(msg: Box<Any + Send>) -> ! {
+pub fn update_count_then_panic(msg: Box<dyn Any + Send>) -> ! {
     update_panic_count(1);
 
-    struct RewrapBox(Box<Any + Send>);
+    struct RewrapBox(Box<dyn Any + Send>);
 
     unsafe impl BoxMeUp for RewrapBox {
-        fn box_me_up(&mut self) -> *mut (Any + Send) {
+        fn box_me_up(&mut self) -> *mut (dyn Any + Send) {
             Box::into_raw(mem::replace(&mut self.0, Box::new(())))
         }
 
-        fn get(&mut self) -> &(Any + Send) {
+        fn get(&mut self) -> &(dyn Any + Send) {
             &*self.0
         }
     }
@@ -517,9 +517,9 @@ fn get(&mut self) -> &(Any + Send) {
 /// 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 BoxMeUp) -> ! {
+pub fn rust_panic(mut msg: &mut dyn BoxMeUp) -> ! {
     let code = unsafe {
-        let obj = &mut msg as *mut &mut BoxMeUp;
+        let obj = &mut msg as *mut &mut dyn BoxMeUp;
         __rust_start_panic(obj as usize)
     };
     rtabort!("failed to initiate panic, error {}", code)
index 00051d4487a214eac90bef8a089468bea345b835..39692836866baab6e7873920c7159ed3bb605be3 100644 (file)
@@ -813,13 +813,13 @@ impl fmt::Debug for Output {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 
         let stdout_utf8 = str::from_utf8(&self.stdout);
-        let stdout_debug: &fmt::Debug = match stdout_utf8 {
+        let stdout_debug: &dyn fmt::Debug = match stdout_utf8 {
             Ok(ref str) => str,
             Err(_) => &self.stdout
         };
 
         let stderr_utf8 = str::from_utf8(&self.stderr);
-        let stderr_debug: &fmt::Debug = match stderr_utf8 {
+        let stderr_debug: &dyn fmt::Debug = match stderr_utf8 {
             Ok(ref str) => str,
             Err(_) => &self.stderr
         };
index 8f945470b7e94b25646f6336a14cfa7d3b84dd1f..9e957bd87d79e3ac4daa224a43847b63b8709150 100644 (file)
@@ -29,7 +29,7 @@
 // To reduce the generated code of the new `lang_start`, this function is doing
 // the real work.
 #[cfg(not(test))]
-fn lang_start_internal(main: &(Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
+fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
                        argc: isize, argv: *const *const u8) -> isize {
     use panic;
     use sys;
index cbda5afadcdfc14858813589527d7ba76615fe14..02a96b01cca28e82ba75d962d6922baa44b3dfca 100644 (file)
@@ -1638,7 +1638,7 @@ fn description(&self) -> &str {
         "sending on a closed channel"
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         None
     }
 }
@@ -1681,7 +1681,7 @@ fn description(&self) -> &str {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         None
     }
 }
@@ -1709,7 +1709,7 @@ fn description(&self) -> &str {
         "receiving on a closed channel"
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         None
     }
 }
@@ -1742,7 +1742,7 @@ fn description(&self) -> &str {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         None
     }
 }
@@ -1783,7 +1783,7 @@ fn description(&self) -> &str {
         }
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         None
     }
 }
index 9310dad9172a9f816436039b0d6bb4e15d836dc6..a7a284cfb7994a766b1d3781c9d5b34e22effdec 100644 (file)
@@ -93,7 +93,7 @@ pub struct Handle<'rx, T:Send+'rx> {
     next: *mut Handle<'static, ()>,
     prev: *mut Handle<'static, ()>,
     added: bool,
-    packet: &'rx (Packet+'rx),
+    packet: &'rx (dyn Packet+'rx),
 
     // due to our fun transmutes, we be sure to place this at the end. (nothing
     // previous relies on T)
index 443e2a6980d9eb85571a8db0bd4dda60211e3547..10282ecb6588370d35aabf305e49173508d6f12d 100644 (file)
@@ -309,7 +309,7 @@ pub fn call_once_force<F>(&self, f: F) where F: FnOnce(&OnceState) {
     #[cold]
     fn call_inner(&self,
                   ignore_poisoning: bool,
-                  init: &mut FnMut(bool)) {
+                  init: &mut dyn FnMut(bool)) {
         let mut state = self.state.load(Ordering::SeqCst);
 
         'outer: loop {
index 5d66936b2a4ff1753e5e735acc7dd9d3e3cf9f96..8cca47efd22d19bb4e152f79da603410926e1a58 100644 (file)
@@ -32,7 +32,7 @@ unsafe impl Send for Thread {}
 unsafe impl Sync for Thread {}
 
 impl Thread {
-    pub unsafe fn new<'a>(stack: usize, p: Box<FnBox() + 'a>) -> io::Result<Thread> {
+    pub unsafe fn new<'a>(stack: usize, p: Box<dyn FnBox() + 'a>) -> io::Result<Thread> {
         let p = box p;
         let mut native: libc::pthread_t = mem::zeroed();
         let mut attr: libc::pthread_attr_t = mem::zeroed();
index d0b94e14f54e93e1c4bd14ee117ca523b604a45c..02bc467541ecad6ec4f7c1a158c77b83cf1d19ba 100644 (file)
@@ -51,7 +51,7 @@ pub struct Command {
     uid: Option<u32>,
     gid: Option<u32>,
     saw_nul: bool,
-    closures: Vec<Box<FnMut() -> io::Result<()> + Send + Sync>>,
+    closures: Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>>,
     stdin: Option<Stdio>,
     stdout: Option<Stdio>,
     stderr: Option<Stdio>,
@@ -122,7 +122,7 @@ pub fn gid(&mut self, id: u32) {
     }
 
     pub fn before_exec(&mut self,
-                       f: Box<FnMut() -> io::Result<()> + Send + Sync>) {
+                       f: Box<dyn FnMut() -> io::Result<()> + Send + Sync>) {
         self.closures.push(f);
     }
 
index 110d46ca3ab0381387efe55e8d39ae97ab9c7631..f4177087d77a1e24cd68dc06f0f5e52fa6332583 100644 (file)
@@ -28,7 +28,7 @@ unsafe impl Send for Thread {}
 unsafe impl Sync for Thread {}
 
 impl Thread {
-    pub unsafe fn new<'a>(_stack: usize, p: Box<FnBox() + 'a>) -> io::Result<Thread> {
+    pub unsafe fn new<'a>(_stack: usize, p: Box<dyn FnBox() + 'a>) -> io::Result<Thread> {
         let p = box p;
 
         let id = cvt(syscall::clone(syscall::CLONE_VM | syscall::CLONE_FS | syscall::CLONE_FILES))?;
index 6396bb3a49e2844c93865187354a0d2338c3b780..77f125f3c5b569b2b9597592f09a53a116149cd9 100644 (file)
@@ -52,7 +52,7 @@ pub struct Command {
     uid: Option<uid_t>,
     gid: Option<gid_t>,
     saw_nul: bool,
-    closures: Vec<Box<FnMut() -> io::Result<()> + Send + Sync>>,
+    closures: Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>>,
     stdin: Option<Stdio>,
     stdout: Option<Stdio>,
     stderr: Option<Stdio>,
@@ -155,12 +155,12 @@ pub fn get_gid(&self) -> Option<gid_t> {
         self.gid
     }
 
-    pub fn get_closures(&mut self) -> &mut Vec<Box<FnMut() -> io::Result<()> + Send + Sync>> {
+    pub fn get_closures(&mut self) -> &mut Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>> {
         &mut self.closures
     }
 
     pub fn before_exec(&mut self,
-                       f: Box<FnMut() -> io::Result<()> + Send + Sync>) {
+                       f: Box<dyn FnMut() -> io::Result<()> + Send + Sync>) {
         self.closures.push(f);
     }
 
index 7fdecc9c0c026aab31787f19f6b7ed3d512706f5..e26306c045d310aa6b9cd99d685ed6b1c6594623 100644 (file)
@@ -49,7 +49,7 @@ unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t,
 }
 
 impl Thread {
-    pub unsafe fn new<'a>(stack: usize, p: Box<FnBox() + 'a>)
+    pub unsafe fn new<'a>(stack: usize, p: Box<dyn FnBox() + 'a>)
                           -> io::Result<Thread> {
         let p = box p;
         let mut native: libc::pthread_t = mem::zeroed();
index 728e678a2e8c193c22b48270bd815a2a54f7c015..8173a62421117d4bb11b034a1bcee3978458a84c 100644 (file)
@@ -19,7 +19,7 @@
 pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
 
 impl Thread {
-    pub unsafe fn new<'a>(_stack: usize, _p: Box<FnBox() + 'a>)
+    pub unsafe fn new<'a>(_stack: usize, _p: Box<dyn FnBox() + 'a>)
         -> io::Result<Thread>
     {
         unsupported()
index b6f63303dc2f0af374d731305059f9c8a45008d5..44ec872b2446b956d85677a5e5d28f60a4a2bc44 100644 (file)
@@ -28,7 +28,7 @@ pub struct Thread {
 }
 
 impl Thread {
-    pub unsafe fn new<'a>(stack: usize, p: Box<FnBox() + 'a>)
+    pub unsafe fn new<'a>(stack: usize, p: Box<dyn FnBox() + 'a>)
                           -> io::Result<Thread> {
         let p = box p;
 
index d268d9ad6f92a6ede331ff86956164a92a8adcdb..b28a4d2f8be016f21bcc2f58b2457eea0c921b10 100644 (file)
@@ -17,7 +17,7 @@
 use mem;
 use sys_common::mutex::Mutex;
 
-type Queue = Vec<Box<FnBox()>>;
+type Queue = Vec<Box<dyn FnBox()>>;
 
 // NB these are specifically not types from `std::sync` as they currently rely
 // on poisoning and this module needs to operate at a lower level than requiring
@@ -68,7 +68,7 @@ pub fn cleanup() {
     }
 }
 
-pub fn push(f: Box<FnBox()>) -> bool {
+pub fn push(f: Box<dyn FnBox()>) -> bool {
     unsafe {
         let _guard = LOCK.lock();
         if init() {
index 2db47bd59475e5feb57b96d1a3ddbfa74b59071b..77371782977b1c6f580d97cee6a5a4c3d4cbb860 100644 (file)
@@ -49,7 +49,7 @@ pub struct Frame {
 const MAX_NB_FRAMES: usize = 100;
 
 /// Prints the current backtrace.
-pub fn print(w: &mut Write, format: PrintFormat) -> io::Result<()> {
+pub fn print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> {
     static LOCK: Mutex = Mutex::new();
 
     // Use a lock to prevent mixed output in multithreading context.
@@ -62,7 +62,7 @@ pub fn print(w: &mut Write, format: PrintFormat) -> io::Result<()> {
     }
 }
 
-fn _print(w: &mut Write, format: PrintFormat) -> io::Result<()> {
+fn _print(w: &mut dyn Write, format: PrintFormat) -> io::Result<()> {
     let mut frames = [Frame {
         exact_position: ptr::null(),
         symbol_addr: ptr::null(),
@@ -176,7 +176,7 @@ pub fn log_enabled() -> Option<PrintFormat> {
 ///
 /// These output functions should now be used everywhere to ensure consistency.
 /// You may want to also use `output_fileline`.
-fn output(w: &mut Write, idx: usize, frame: Frame,
+fn output(w: &mut dyn Write, idx: usize, frame: Frame,
               s: Option<&str>, format: PrintFormat) -> io::Result<()> {
     // Remove the `17: 0x0 - <unknown>` line.
     if format == PrintFormat::Short && frame.exact_position == ptr::null() {
@@ -201,7 +201,7 @@ fn output(w: &mut Write, idx: usize, frame: Frame,
 ///
 /// See also `output`.
 #[allow(dead_code)]
-fn output_fileline(w: &mut Write,
+fn output_fileline(w: &mut dyn Write,
                    file: &[u8],
                    line: u32,
                    format: PrintFormat) -> io::Result<()> {
@@ -253,7 +253,7 @@ fn output_fileline(w: &mut Write,
 // Note that this demangler isn't quite as fancy as it could be. We have lots
 // of other information in our symbols like hashes, version, type information,
 // etc. Additionally, this doesn't handle glue symbols at all.
-pub fn demangle(writer: &mut Write, mut s: &str, format: PrintFormat) -> io::Result<()> {
+pub fn demangle(writer: &mut dyn Write, mut s: &str, format: PrintFormat) -> io::Result<()> {
     // During ThinLTO LLVM may import and rename internal symbols, so strip out
     // those endings first as they're one of the last manglings applied to
     // symbol names.
index e74c40ae04b5d4ed55ad64921fa43db2f2c60fbe..1625efe4a2ae7142a06023a31b1058991a2bcdd8 100644 (file)
@@ -251,7 +251,7 @@ fn description(&self) -> &str {
         }
     }
 
-    fn cause(&self) -> Option<&Error> {
+    fn cause(&self) -> Option<&dyn Error> {
         match *self {
             TryLockError::Poisoned(ref p) => Some(p),
             _ => None
index da6f58ef6bb7724952ef73162a75b6bec26491f0..86a5e2b86942a4e6b7740ab158371942fb37a768 100644 (file)
@@ -21,7 +21,7 @@ pub unsafe fn start_thread(main: *mut u8) {
     let _handler = stack_overflow::Handler::new();
 
     // Finally, let's run some code.
-    Box::from_raw(main as *mut Box<FnBox()>)()
+    Box::from_raw(main as *mut Box<dyn FnBox()>)()
 }
 
 pub fn min_stack() -> usize {
index 90f054186d16118a7a1ae3a841240c21daa65f73..ae804ad409ee311fdbb73b7b582cd9b2176b1974 100644 (file)
@@ -1175,7 +1175,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 ///
 /// [`Result`]: ../../std/result/enum.Result.html
 #[stable(feature = "rust1", since = "1.0.0")]
-pub type Result<T> = ::result::Result<T, Box<Any + Send + 'static>>;
+pub type Result<T> = ::result::Result<T, Box<dyn Any + Send + 'static>>;
 
 // This packet is used to communicate the return value between the child thread
 // and the parent thread. Memory is shared through the `Arc` within and there's
@@ -1276,6 +1276,11 @@ fn join(&mut self) -> Result<T> {
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct JoinHandle<T>(JoinInner<T>);
 
+#[stable(feature = "joinhandle_impl_send_sync", since = "1.29.0")]
+unsafe impl<T> Send for JoinHandle<T> {}
+#[stable(feature = "joinhandle_impl_send_sync", since = "1.29.0")]
+unsafe impl<T> Sync for JoinHandle<T> {}
+
 impl<T> JoinHandle<T> {
     /// Extracts a handle to the underlying thread.
     ///
@@ -1438,7 +1443,7 @@ fn test_spawn_sched_childs_on_default_sched() {
         rx.recv().unwrap();
     }
 
-    fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Box<Fn() + Send>) {
+    fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Box<dyn Fn() + Send>) {
         let (tx, rx) = channel();
 
         let x: Box<_> = box 1;
@@ -1485,7 +1490,7 @@ fn test_child_doesnt_ref_parent() {
         // (well, it would if the constant were 8000+ - I lowered it to be more
         // valgrind-friendly. try this at home, instead..!)
         const GENERATIONS: u32 = 16;
-        fn child_no(x: u32) -> Box<Fn() + Send> {
+        fn child_no(x: u32) -> Box<dyn Fn() + Send> {
             return Box::new(move|| {
                 if x < GENERATIONS {
                     thread::spawn(move|| child_no(x+1)());
@@ -1531,10 +1536,10 @@ fn test_try_panic_message_owned_str() {
     #[test]
     fn test_try_panic_message_any() {
         match thread::spawn(move|| {
-            panic!(box 413u16 as Box<Any + Send>);
+            panic!(box 413u16 as Box<dyn Any + Send>);
         }).join() {
             Err(e) => {
-                type T = Box<Any + Send>;
+                type T = Box<dyn Any + Send>;
                 assert!(e.is::<T>());
                 let any = e.downcast::<T>().unwrap();
                 assert!(any.is::<u16>());
index d241ae1d44227bd4f0539abb06bba18e8f453f6e..60de94821bba0ba7b87a9a634ab74c36a4d5fa22 100644 (file)
@@ -14,8 +14,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/",
index 64309dd9b8b93f2e9274325f4201c769195e545f..56760546c50881e9f9df63e8b385629eb979c9f5 100644 (file)
@@ -6514,6 +6514,39 @@ fn parse_item_foreign_type(&mut self, vis: ast::Visibility, lo: Span, attrs: Vec
         })
     }
 
+    fn parse_crate_name_with_dashes(&mut self) -> PResult<'a, ast::Ident> {
+        let error_msg = "crate name using dashes are not valid in `extern crate` statements";
+        let suggestion_msg = "if the original crate name uses dashes you need to use underscores \
+                              in the code";
+        let mut ident = self.parse_ident()?;
+        let mut idents = vec![];
+        let mut replacement = vec![];
+        let mut fixed_crate_name = false;
+        // Accept `extern crate name-like-this` for better diagnostics
+        let dash = token::Token::BinOp(token::BinOpToken::Minus);
+        if self.token == dash {  // Do not include `-` as part of the expected tokens list
+            while self.eat(&dash) {
+                fixed_crate_name = true;
+                replacement.push((self.prev_span, "_".to_string()));
+                idents.push(self.parse_ident()?);
+            }
+        }
+        if fixed_crate_name {
+            let fixed_name_sp = ident.span.to(idents.last().unwrap().span);
+            let mut fixed_name = format!("{}", ident.name);
+            for part in idents {
+                fixed_name.push_str(&format!("_{}", part.name));
+            }
+            ident = Ident::from_str(&fixed_name).with_span_pos(fixed_name_sp);
+
+            let mut err = self.struct_span_err(fixed_name_sp, error_msg);
+            err.span_label(fixed_name_sp, "dash-separated idents are not valid");
+            err.multipart_suggestion(suggestion_msg, replacement);
+            err.emit();
+        }
+        Ok(ident)
+    }
+
     /// Parse extern crate links
     ///
     /// # Examples
@@ -6525,7 +6558,8 @@ fn parse_item_extern_crate(&mut self,
                                visibility: Visibility,
                                attrs: Vec<Attribute>)
                                -> PResult<'a, P<Item>> {
-        let orig_name = self.parse_ident()?;
+        // Accept `extern crate name-like-this` for better diagnostics
+        let orig_name = self.parse_crate_name_with_dashes()?;
         let (item_name, orig_name) = if let Some(rename) = self.parse_rename()? {
             (rename, Some(orig_name.name))
         } else {
index ff76e788b3c291311b24afa70ca9267126a85d55..f0d33835cd0fbf730754419dee276b3dcaeb0940 100644 (file)
@@ -10,8 +10,6 @@
 
 //! Syntax extensions in the Rust compiler.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
        html_root_url = "https://doc.rust-lang.org/nightly/")]
index cc09a944e4ccc1168d46a6c812d841d7178e76de..734f76e499908b172899792e527b540d8877fde7 100644 (file)
@@ -14,8 +14,6 @@
 //!
 //! This API is completely unstable and subject to change.
 
-#![deny(bare_trait_objects)]
-
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
       html_root_url = "https://doc.rust-lang.org/nightly/")]
@@ -634,15 +632,14 @@ pub fn replace(&mut self, before: Span, after: Span) -> bool {
     /// `SpanLabel` instances with empty labels.
     pub fn span_labels(&self) -> Vec<SpanLabel> {
         let is_primary = |span| self.primary_spans.contains(&span);
-        let mut span_labels = vec![];
 
-        for &(span, ref label) in &self.span_labels {
-            span_labels.push(SpanLabel {
+        let mut span_labels = self.span_labels.iter().map(|&(span, ref label)|
+            SpanLabel {
                 span,
                 is_primary: is_primary(span),
                 label: Some(label.clone())
-            });
-        }
+            }
+        ).collect::<Vec<_>>();
 
         for &span in &self.primary_spans {
             if !span_labels.iter().any(|sl| sl.span == span) {
index a012f4e776fb21b69ed8ddbd10ae4bad44f43372..cf92ce27ee58732700940a0c940dda19efac3244 100644 (file)
@@ -66,9 +66,9 @@
 mod win;
 
 /// Alias for stdout terminals.
-pub type StdoutTerminal = Terminal<Output = Stdout> + Send;
+pub type StdoutTerminal = dyn Terminal<Output = Stdout> + Send;
 /// Alias for stderr terminals.
-pub type StderrTerminal = Terminal<Output = Stderr> + Send;
+pub type StderrTerminal = dyn Terminal<Output = Stderr> + Send;
 
 #[cfg(not(windows))]
 /// Return a Terminal wrapping stdout, or None if a terminal couldn't be
index c5e68eed4072541a2e81630dcc15345a8bd09122..51e0fa315f43538a78fe573d88ec306570ad248a 100644 (file)
@@ -58,7 +58,7 @@ fn description(&self) -> &str {
         "failed to create TermInfo"
     }
 
-    fn cause(&self) -> Option<&error::Error> {
+    fn cause(&self) -> Option<&dyn error::Error> {
         use self::Error::*;
         match self {
             &IoError(ref e) => Some(e),
index 0cdea64db8bc09c74bf8d35d883130da52ab76f5..d5e5df547334c28bfa544ea4e9708113c1cb729f 100644 (file)
     "OTG3", "OTG1", "OTG4", "OTGR", "OTGL", "OTGU", "OTGD", "OTGH", "OTGV", "OTGC", "meml", "memu",
     "box1"];
 
-fn read_le_u16(r: &mut io::Read) -> io::Result<u16> {
+fn read_le_u16(r: &mut dyn io::Read) -> io::Result<u16> {
     let mut b = [0; 2];
     let mut amt = 0;
     while amt < b.len() {
@@ -176,7 +176,7 @@ fn read_le_u16(r: &mut io::Read) -> io::Result<u16> {
     Ok((b[0] as u16) | ((b[1] as u16) << 8))
 }
 
-fn read_byte(r: &mut io::Read) -> io::Result<u8> {
+fn read_byte(r: &mut dyn io::Read) -> io::Result<u8> {
     match r.bytes().next() {
         Some(s) => s,
         None => Err(io::Error::new(io::ErrorKind::Other, "end of file")),
@@ -185,7 +185,7 @@ fn read_byte(r: &mut io::Read) -> io::Result<u8> {
 
 /// Parse a compiled terminfo entry, using long capability names if `longnames`
 /// is true
-pub fn parse(file: &mut io::Read, longnames: bool) -> Result<TermInfo, String> {
+pub fn parse(file: &mut dyn io::Read, longnames: bool) -> Result<TermInfo, String> {
     macro_rules! t( ($e:expr) => (
         match $e {
             Ok(e) => e,
index 6b547dff9120ed3e97702933bf4dfd4431c78c32..76206e2c10d11b4dd208cf42c66e411558c5208b 100644 (file)
@@ -27,8 +27,6 @@
 // this crate, which relies on this attribute (rather than the value of `--crate-name` passed by
 // cargo) to detect this crate.
 
-#![deny(bare_trait_objects)]
-
 #![crate_name = "test"]
 #![unstable(feature = "test", issue = "27812")]
 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
index ea5eee3cc7d46d60abac92e8bcab9c0804cddc49..2b3c19c067ed4258de5a3da04fc6ae1b754a2168 100644 (file)
@@ -8,8 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![deny(bare_trait_objects)]
-
 #![no_std]
 #![unstable(feature = "panic_unwind", issue = "32837")]
 
index f2c0e9e3b2aa5fd8ca0cee659434b39d92a481d8..aa6339c852221ed7a37f75357c37323bb0ec8302 100644 (file)
@@ -12,7 +12,7 @@
 # source tarball for a stable release you'll likely see `1.x.0` for rustc and
 # `0.x.0` for Cargo where they were released on `date`.
 
-date: 2018-07-13
+date: 2018-07-27
 rustc: beta
 cargo: beta
 
diff --git a/src/test/ui/bad-crate-name.rs b/src/test/ui/bad-crate-name.rs
new file mode 100644 (file)
index 0000000..70e1806
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+extern crate krate-name-here;
+//~^ ERROR crate name using dashes are not valid in `extern crate` statements
+//~| ERROR can't find crate for `krate_name_here`
+
+fn main() {}
diff --git a/src/test/ui/bad-crate-name.stderr b/src/test/ui/bad-crate-name.stderr
new file mode 100644 (file)
index 0000000..8348bad
--- /dev/null
@@ -0,0 +1,19 @@
+error: crate name using dashes are not valid in `extern crate` statements
+  --> $DIR/bad-crate-name.rs:11:14
+   |
+LL | extern crate krate-name-here;
+   |              ^^^^^^^^^^^^^^^ dash-separated idents are not valid
+help: if the original crate name uses dashes you need to use underscores in the code
+   |
+LL | extern crate krate_name_here;
+   |                   ^    ^
+
+error[E0463]: can't find crate for `krate_name_here`
+  --> $DIR/bad-crate-name.rs:11:1
+   |
+LL | extern crate krate-name-here;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0463`.
diff --git a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.edition.stderr
new file mode 100644 (file)
index 0000000..fa82efa
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0507]: cannot move out of borrowed content
+  --> $DIR/borrowck-feature-nll-overrides-migrate.rs:32:17
+   |
+LL |                 (|| { let bar = foo; bar.take() })();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.rs b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.rs
new file mode 100644 (file)
index 0000000..7204393
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This is a test that the `#![feature(nll)]` opt-in overrides the
+// migration mode. The intention here is to emulate the goal behavior
+// that `--edition 2018` effects on borrowck (modeled here by `-Z
+// borrowck=migrate`) are themselves overridden by the
+// `#![feature(nll)]` opt-in.
+//
+// Therefore, for developer convenience, under `#[feature(nll)]` the
+// NLL checks will be emitted as errors *even* in the presence of `-Z
+// borrowck=migrate`.
+
+// revisions: zflag edition
+// [zflag]compile-flags: -Z borrowck=migrate
+// [edition]compile-flags: --edition 2018
+
+#![feature(nll)]
+
+fn main() {
+    match Some(&4) {
+        None => {},
+        ref mut foo
+            if {
+                (|| { let bar = foo; bar.take() })();
+                //[zflag]~^ ERROR cannot move out of borrowed content [E0507]
+                //[edition]~^^ ERROR cannot move out of borrowed content [E0507]
+                false
+            } => {},
+        Some(ref _s) => println!("Note this arm is bogus; the `Some` became `None` in the guard."),
+        _ => println!("Here is some supposedly unreachable code."),
+    }
+}
diff --git a/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr b/src/test/ui/borrowck/borrowck-feature-nll-overrides-migrate.zflag.stderr
new file mode 100644 (file)
index 0000000..fa82efa
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0507]: cannot move out of borrowed content
+  --> $DIR/borrowck-feature-nll-overrides-migrate.rs:32:17
+   |
+LL |                 (|| { let bar = foo; bar.take() })();
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot move out of borrowed content
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.
diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr b/src/test/ui/borrowck/borrowck-migrate-to-nll.edition.stderr
new file mode 100644 (file)
index 0000000..f5a9db3
--- /dev/null
@@ -0,0 +1,24 @@
+warning[E0507]: cannot move out of borrowed content
+  --> $DIR/borrowck-migrate-to-nll.rs:35:17
+   |
+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/borrowck-migrate-to-nll.rs:35:17
+   |
+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.
+
diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.rs b/src/test/ui/borrowck/borrowck-migrate-to-nll.rs
new file mode 100644 (file)
index 0000000..e7f2bfb
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// This is a test of the borrowck migrate mode. It leverages #27282, a
+// bug that is fixed by NLL: this code is (unsoundly) accepted by
+// AST-borrowck, but is correctly rejected by the NLL borrowck.
+//
+// Therefore, for backwards-compatiblity, under borrowck=migrate the
+// NLL checks will be emitted as *warnings*.
+
+// NLL mode makes this compile-fail; we cannot currently encode a
+// test that is run-pass or compile-fail based on compare-mode. So
+// just ignore it instead:
+
+// ignore-compare-mode-nll
+
+// revisions: zflag edition
+//[zflag]compile-flags: -Z borrowck=migrate
+//[edition]compile-flags: --edition 2018
+//[zflag] run-pass
+//[edition] run-pass
+
+fn main() {
+    match Some(&4) {
+        None => {},
+        ref mut foo
+            if {
+                (|| { let bar = foo; bar.take() })();
+                false
+            } => {},
+        Some(ref _s) => println!("Note this arm is bogus; the `Some` became `None` in the guard."),
+        _ => println!("Here is some supposedly unreachable code."),
+    }
+}
diff --git a/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr b/src/test/ui/borrowck/borrowck-migrate-to-nll.zflag.stderr
new file mode 100644 (file)
index 0000000..f5a9db3
--- /dev/null
@@ -0,0 +1,24 @@
+warning[E0507]: cannot move out of borrowed content
+  --> $DIR/borrowck-migrate-to-nll.rs:35:17
+   |
+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/borrowck-migrate-to-nll.rs:35:17
+   |
+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.
+
diff --git a/src/test/ui/borrowck/issue-51348-multi-ref-mut-in-guard.rs b/src/test/ui/borrowck/issue-51348-multi-ref-mut-in-guard.rs
new file mode 100644 (file)
index 0000000..c9d39fa
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// We used to ICE if you had a single match arm with multiple
+// candidate patterns with `ref mut` identifiers used in the arm's
+// guard.
+//
+// Also, this test expands on the original bug's example by actually
+// trying to double check that we are matching against the right part
+// of the input data based on which candidate pattern actually fired.
+
+// run-pass
+
+#![feature(nll)]
+
+fn foo(x: &mut Result<(u32, u32), (u32, u32)>) -> u32 {
+    match *x {
+        Ok((ref mut v, _)) | Err((_, ref mut v)) if *v > 0 => { *v }
+        _ => { 0 }
+    }
+}
+
+fn main() {
+    assert_eq!(foo(&mut Ok((3, 4))), 3);
+    assert_eq!(foo(&mut Err((3, 4))), 4);
+}
index 9c7e3db67a611a55676afa41b85e1ec1671e59ca..0ac295c54bccbb34ae8206916228d87fbd2e51f0 100644 (file)
@@ -10,8 +10,8 @@ error: unsatisfied lifetime constraints
 LL |     invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
    |                ----------^^^^^-----------------
    |                |   |     |
-   |                |   |     free region requires that `'1` must outlive `'2`
-   |                |   lifetime `'1` appears in this argument
+   |                |   |     requires that `'1` must outlive `'2`
+   |                |   has type `&'1 i32`
    |                lifetime `'2` appears in return type
 
 error: aborting due to previous error
index 3223ff4dc8b5900b95eafdd3b69049f226b5d88d..fdfe9e2c562e0395d6d8e9726e97351c91a73182 100644 (file)
@@ -8,17 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// compile-flags: -Z borrowck=compare
-
 #![feature(generators)]
 #![feature(nll)]
 
 fn main() {
     || {
         // The reference in `_a` is a Legal with NLL since it ends before the yield
-        let _a = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
-        let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
-        //~^ borrow may still be in use when generator yields (Mir)
+        let _a = &mut true;
+        let b = &mut true;
+        //~^ borrow may still be in use when generator yields
         yield ();
         println!("{}", b);
     };
index 7e39d3c545903650eea43fd8057978ca975f24fb..1dc663d8bcbf7f1ea4ba4687a0bd99c2c7ef1671 100644 (file)
@@ -1,30 +1,12 @@
-error[E0626]: borrow may still be in use when generator yields (Ast)
-  --> $DIR/generator-with-nll.rs:19:23
+error[E0626]: borrow may still be in use when generator yields
+  --> $DIR/generator-with-nll.rs:18:17
    |
-LL |         let _a = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
-   |                       ^^^^
-...
-LL |         yield ();
-   |         -------- possible yield occurs here
-
-error[E0626]: borrow may still be in use when generator yields (Ast)
-  --> $DIR/generator-with-nll.rs:20:22
-   |
-LL |         let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
-   |                      ^^^^
-LL |         //~^ borrow may still be in use when generator yields (Mir)
-LL |         yield ();
-   |         -------- possible yield occurs here
-
-error[E0626]: borrow may still be in use when generator yields (Mir)
-  --> $DIR/generator-with-nll.rs:20:17
-   |
-LL |         let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast)
+LL |         let b = &mut true;
    |                 ^^^^^^^^^
-LL |         //~^ borrow may still be in use when generator yields (Mir)
+LL |         //~^ borrow may still be in use when generator yields
 LL |         yield ();
    |         -------- possible yield occurs here
 
-error: aborting due to 3 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0626`.
diff --git a/src/test/ui/impl-trait/associated-existential-type-generic-trait.rs b/src/test/ui/impl-trait/associated-existential-type-generic-trait.rs
new file mode 100644 (file)
index 0000000..c9bf7b8
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+// compile-pass
+
+trait Bar {}
+struct Dummy<U>(U);
+impl<V> Bar for Dummy<V> {}
+
+trait Foo<T> {
+    type Assoc: Bar;
+    fn foo(t: T) -> Self::Assoc;
+}
+
+impl<W> Foo<W> for i32 {
+    existential type Assoc: Bar;
+    fn foo(w: W) -> Self::Assoc {
+        Dummy(w)
+    }
+}
+
+struct NonGeneric;
+impl Bar for NonGeneric {}
+
+impl<W> Foo<W> for u32 {
+    existential type Assoc: Bar;
+    fn foo(_: W) -> Self::Assoc {
+        NonGeneric
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/associated-existential-type-trivial.rs b/src/test/ui/impl-trait/associated-existential-type-trivial.rs
new file mode 100644 (file)
index 0000000..78593fe
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+// compile-pass
+
+trait Bar {}
+struct Dummy;
+impl Bar for Dummy {}
+
+trait Foo {
+    type Assoc: Bar;
+    fn foo() -> Self::Assoc;
+}
+
+impl Foo for i32 {
+    existential type Assoc: Bar;
+    fn foo() -> Self::Assoc {
+        Dummy
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/associated-existential-type.rs b/src/test/ui/impl-trait/associated-existential-type.rs
new file mode 100644 (file)
index 0000000..d880428
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(existential_type)]
+// compile-pass
+
+trait Bar {}
+struct Dummy;
+impl Bar for Dummy {}
+
+trait Foo {
+    type Assoc: Bar;
+    fn foo() -> Self::Assoc;
+    fn bar() -> Self::Assoc;
+}
+
+impl Foo for i32 {
+    existential type Assoc: Bar;
+    fn foo() -> Self::Assoc {
+        Dummy
+    }
+    fn bar() -> Self::Assoc {
+        Dummy
+    }
+}
+
+fn main() {}
index c6f8d2e519ca1c7909aca8cb49c3c354cb6c6bd7..bbc63e6fecaf5c7b790f1c9bf64e2a0720d98e61 100644 (file)
@@ -10,21 +10,19 @@ warning: not reporting region error due to nll
 LL |         self.x.iter().map(|a| a.0)
    |                ^^^^
 
-error: borrowed data escapes outside of closure
+error: unsatisfied lifetime constraints
   --> $DIR/static-return-lifetime-infered.rs:17:9
    |
 LL |     fn iter_values_anon(&self) -> impl Iterator<Item=u32> {
-   |                         ----- `self` is a reference that is only valid in the closure body
+   |                         - let's call the lifetime of this reference `'1`
 LL |         self.x.iter().map(|a| a.0)
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` escapes the closure body here
+   |         ^^^^^^^^^^^^^ requires that `'1` must outlive `'static`
 
-error: borrowed data escapes outside of closure
+error: unsatisfied lifetime constraints
   --> $DIR/static-return-lifetime-infered.rs:21:9
    |
-LL |     fn iter_values<'a>(&'a self) -> impl Iterator<Item=u32> {
-   |                        -------- `self` is a reference that is only valid in the closure body
 LL |         self.x.iter().map(|a| a.0)
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` escapes the closure body here
+   |         ^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
 
 error: aborting due to 2 previous errors
 
index e26b1956d5e819632e0fb6d090636b36837f6375..f5d98e04ad804009fdef311814c7c8eaaa86076c 100644 (file)
@@ -4,13 +4,13 @@ warning: not reporting region error due to nll
 LL |     static_val(x); //~ ERROR cannot infer
    |                ^
 
-error: borrowed data escapes outside of closure
+error: borrowed data escapes outside of function
   --> $DIR/dyn-trait.rs:32:5
    |
 LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
-   |                              - `x` is a reference that is only valid in the closure body
+   |                              - `x` is a reference that is only valid in the function body
 LL |     static_val(x); //~ ERROR cannot infer
-   |     ^^^^^^^^^^^^^ `x` escapes the closure body here
+   |     ^^^^^^^^^^^^^ `x` escapes the function body here
 
 error: aborting due to previous error
 
index 1358fe010b443c5d8a607c5a908973e41adc9cc7..6de00ffd48cc1ddd230c715d4c922ed6cae74491 100644 (file)
@@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
   --> $DIR/issue-10291.rs:12:5
    |
 LL |     drop::<Box<for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ free region requires that `'x` must outlive `'static`
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'x` must outlive `'static`
 
 error: aborting due to previous error
 
index 2db3cb80a819e53fd4190eda2325d48e3fba04d5..f06d7360d85b09cdb5efe8deaedcf878e755c995 100644 (file)
@@ -9,6 +9,10 @@ LL |     fn bar(&mut self, other: &Foo) {}
    |
    = note: expected type `fn(&mut Baz, &mut dyn Foo)`
               found type `fn(&mut Baz, &dyn Foo)`
+help: consider change the type to match the mutability in trait
+   |
+LL |     fn bar(&mut self, other: &mut Foo) {}
+   |                              ^^^^^^^^
 
 error: aborting due to previous error
 
index f9dda27da0985b36f5d022e4598a1ca6783a859a..890bb426441e2182b569952ec8dfcbaa4c1805db 100644 (file)
@@ -10,13 +10,13 @@ warning: not reporting region error due to nll
 LL |         self.a(); //~ ERROR cannot infer
    |              ^
 
-error: borrowed data escapes outside of closure
+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 closure body
+   |          ----- `self` is a reference that is only valid in the function body
 LL |         self.a(); //~ ERROR cannot infer
-   |         ^^^^^^^^ `self` escapes the closure body here
+   |         ^^^^^^^^ `self` escapes the function body here
 
 error: aborting due to previous error
 
index 5775135aefc5feb472aaed348d862134190e0f28..c51a72f885d6c83487eab1d2cbb8c07375e06403 100644 (file)
@@ -10,13 +10,13 @@ warning: not reporting region error due to nll
 LL |         self.foo();
    |              ^^^
 
-error: borrowed data escapes outside of closure
+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 closure body
+   |            ----- `self` is a reference that is only valid in the function body
 LL |         self.foo();
-   |         ^^^^^^^^^^ `self` escapes the closure body here
+   |         ^^^^^^^^^^ `self` escapes the function body here
 
 error: aborting due to previous error
 
index 73a8d58290dfaf7c594eaaa014d4566cbf98168c..312ec6e742e9164b4e276828cb51a247f2441a1f 100644 (file)
@@ -6,7 +6,7 @@ LL |        || {
    |  |_____|
    | ||
 LL | ||         &mut x
-   | ||         ^^^^^^ free region requires that `'1` must outlive `'2`
+   | ||         ^^^^^^ return requires that `'1` must outlive `'2`
 LL | ||     };
    | ||     -
    | ||_____|
index 4133c69f031a563c21d09925871bcd747600dd92..eb44850e639abbf3d683bd1fde79402f3a51b942 100644 (file)
@@ -9,7 +9,7 @@ LL |  ||         || {
    |  ||_________^
 LL | |||             x.push(())
 LL | |||         }
-   | |||_________^ free region requires that `'1` must outlive `'2`
+   | |||_________^ requires that `'1` must outlive `'2`
 LL |  ||     };
    |  ||     -
    |  ||_____|
index c288cf9ed820c8dc2f8baf8034570d49847d8214..7dd513d1b712c2e31fd8a016664b021fb3ff114c 100644 (file)
@@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
   --> $DIR/issue-52213.rs:13:11
    |
 LL |         ((u,),) => u,
-   |           ^ free region requires that `'a` must outlive `'b`
+   |           ^ requires that `'a` must outlive `'b`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issue-52533-1.nll.stderr b/src/test/ui/issue-52533-1.nll.stderr
new file mode 100644 (file)
index 0000000..87fda1d
--- /dev/null
@@ -0,0 +1,17 @@
+warning: not reporting region error due to nll
+  --> $DIR/issue-52533-1.rs:19:18
+   |
+LL |     gimme(|x, y| y)
+   |                  ^
+
+error: unsatisfied lifetime constraints
+  --> $DIR/issue-52533-1.rs:19:18
+   |
+LL |     gimme(|x, y| y)
+   |            -  -  ^ closure was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2`
+   |            |  |
+   |            |  has type `&Foo<'_, '1, u32>`
+   |            has type `&Foo<'_, '2, u32>`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/issue-52533-1.rs b/src/test/ui/issue-52533-1.rs
new file mode 100644 (file)
index 0000000..22af5a8
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![allow(warnings)]
+
+struct Foo<'a, 'b, T: 'a + 'b> { x: &'a T, y: &'b T }
+
+fn gimme(_: impl for<'a, 'b, 'c> FnOnce(&'a Foo<'a, 'b, u32>,
+                                        &'a Foo<'a, 'c, u32>) -> &'a Foo<'a, 'b, u32>) { }
+
+fn main() {
+    gimme(|x, y| y)
+    //~^ ERROR mismatched types [E0308]
+}
diff --git a/src/test/ui/issue-52533-1.stderr b/src/test/ui/issue-52533-1.stderr
new file mode 100644 (file)
index 0000000..38deb7d
--- /dev/null
@@ -0,0 +1,22 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-52533-1.rs:19:18
+   |
+LL |     gimme(|x, y| y)
+   |                  ^ lifetime mismatch
+   |
+   = note: expected type `&Foo<'_, '_, u32>`
+              found type `&Foo<'_, '_, u32>`
+note: the anonymous lifetime #4 defined on the body at 19:11...
+  --> $DIR/issue-52533-1.rs:19:11
+   |
+LL |     gimme(|x, y| y)
+   |           ^^^^^^^^
+note: ...does not necessarily outlive the anonymous lifetime #3 defined on the body at 19:11
+  --> $DIR/issue-52533-1.rs:19:11
+   |
+LL |     gimme(|x, y| y)
+   |           ^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/issue-52533.nll.stderr b/src/test/ui/issue-52533.nll.stderr
new file mode 100644 (file)
index 0000000..a13b06e
--- /dev/null
@@ -0,0 +1,17 @@
+warning: not reporting region error due to nll
+  --> $DIR/issue-52533.rs:15:16
+   |
+LL |     foo(|a, b| b)
+   |                ^
+
+error: unsatisfied lifetime constraints
+  --> $DIR/issue-52533.rs:15:16
+   |
+LL |     foo(|a, b| b)
+   |          -  -  ^ closure was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2`
+   |          |  |
+   |          |  has type `&'1 u32`
+   |          has type `&'2 u32`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/issue-52533.rs b/src/test/ui/issue-52533.rs
new file mode 100644 (file)
index 0000000..08f2805
--- /dev/null
@@ -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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn foo(_: impl for<'a> FnOnce(&'a u32, &u32) -> &'a u32) {
+}
+
+fn main() {
+    foo(|a, b| b)
+    //~^ ERROR lifetime of reference outlives lifetime of borrowed content...
+}
diff --git a/src/test/ui/issue-52533.stderr b/src/test/ui/issue-52533.stderr
new file mode 100644 (file)
index 0000000..76a2470
--- /dev/null
@@ -0,0 +1,20 @@
+error[E0312]: lifetime of reference outlives lifetime of borrowed content...
+  --> $DIR/issue-52533.rs:15:16
+   |
+LL |     foo(|a, b| b)
+   |                ^
+   |
+note: ...the reference is valid for the anonymous lifetime #2 defined on the body at 15:9...
+  --> $DIR/issue-52533.rs:15:9
+   |
+LL |     foo(|a, b| b)
+   |         ^^^^^^^^
+note: ...but the borrowed content is only valid for the anonymous lifetime #3 defined on the body at 15:9
+  --> $DIR/issue-52533.rs:15:9
+   |
+LL |     foo(|a, b| b)
+   |         ^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0312`.
index 1b16694bf2c4d8ff3a6328d8f7adaa4d50340ddb..f707a600f29e34d989996198e46f123e74fcd614 100644 (file)
@@ -21,6 +21,10 @@ LL |     fn bar(&mut self) { }
    |
    = note: expected type `fn(&Bar)`
               found type `fn(&mut Bar)`
+help: consider change the type to match the mutability in trait
+   |
+LL |     fn bar(&self) { }
+   |            ^^^^^
 
 error: aborting due to 2 previous errors
 
index 28b16641e4dd54234e26bfad13f1d5b41cf4acda..631af21cac5ca893ffdbd862766d943bbcb3512e 100644 (file)
@@ -21,6 +21,10 @@ LL |     fn bar(&mut self, bar: &Bar) { } //~ ERROR incompatible type
    |
    = note: expected type `fn(&mut Bar, &mut Bar)`
               found type `fn(&mut Bar, &Bar)`
+help: consider change the type to match the mutability in trait
+   |
+LL |     fn bar(&mut self, bar: &mut Bar) { } //~ ERROR incompatible type
+   |                            ^^^^^^^^
 
 error: aborting due to 2 previous errors
 
index d6f542183603ec522f9cce71ea9312659b47a7c9..ccf116e640d429ec4fed4e09a447664a93a65af5 100644 (file)
@@ -8,10 +8,10 @@ error: unsatisfied lifetime constraints
   --> $DIR/escape-argument-callee.rs:36:45
    |
 LL |         let mut closure = expect_sig(|p, y| *p = y);
-   |                                       -  -  ^^^^^^ free region requires that `'1` must outlive `'2`
+   |                                       -  -  ^^^^^^ requires that `'1` must outlive `'2`
    |                                       |  |
-   |                                       |  lifetime `'1` appears in this argument
-   |                                       lifetime `'2` appears in this argument
+   |                                       |  has type `&'1 i32`
+   |                                       has type `&mut &'2 i32`
 
 note: No external requirements
   --> $DIR/escape-argument-callee.rs:36:38
index a7a50a3a029817e099b4a2433a4ac47608c4f135..b4508824901952cf390beed9727c9cc355285330 100644 (file)
@@ -8,9 +8,9 @@ error: unsatisfied lifetime constraints
   --> $DIR/propagate-approximated-fail-no-postdom.rs:57:13
    |
 LL |         |_outlives1, _outlives2, _outlives3, x, y| {
-   |          ----------              ---------- lifetime `'2` appears in this argument
+   |          ----------              ---------- has type `std::cell::Cell<&'2 &u32>`
    |          |
-   |          lifetime `'1` appears in this argument
+   |          has type `std::cell::Cell<&&'1 u32>`
 ...
 LL |             demand_y(x, y, p) //~ ERROR
    |             ^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
index 3177cd7c28f647991730cc80908e060b638d12d8..33e4240736f5bfdd7c8ad17cf6bb0218ac0cddaa 100644 (file)
@@ -23,18 +23,18 @@ LL | |     });
    = note: number of external vids: 2
    = note: where '_#1r: '_#0r
 
-error: borrowed data escapes outside of closure
+error: 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 closure body
+   |                     ------ `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
 LL | |
 LL | |         // Only works if 'x: 'y:
 LL | |         demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll
 LL | |     });
-   | |______^ `cell_a` escapes the closure body here
+   | |______^ `cell_a` escapes the function body here
 
 note: No external requirements
   --> $DIR/propagate-approximated-shorter-to-static-no-bound.rs:44:1
index 089c88abcdd4aee5ae8fed1eed5a8630597668ed..5f98a0fd36d7989414fb691283e84b221add3b04 100644 (file)
@@ -23,18 +23,18 @@ LL | |     });
    = note: number of external vids: 3
    = note: where '_#1r: '_#0r
 
-error: borrowed data escapes outside of closure
+error: 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 closure body
+   |                     ------ `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
 LL | |         // Only works if 'x: 'y:
 LL | |         demand_y(x, y, x.get())
 LL | |         //~^ WARNING not reporting region error due to nll
 LL | |     });
-   | |______^ `cell_a` escapes the closure body here
+   | |______^ `cell_a` escapes the function body here
 
 note: No external requirements
   --> $DIR/propagate-approximated-shorter-to-static-wrong-bound.rs:47:1
index fb98c506c7d280a913b785441d731b06f4f7c1d7..40ebda4419b2a09aa07d3d7331692ea47c501feb 100644 (file)
@@ -8,9 +8,9 @@ error: unsatisfied lifetime constraints
   --> $DIR/propagate-fail-to-approximate-longer-no-bounds.rs:47:9
    |
 LL |     establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
-   |                                                ---------  - lifetime `'1` appears in this argument
+   |                                                ---------  - has type `&std::cell::Cell<&'1 u32>`
    |                                                |
-   |                                                lifetime `'2` appears in this argument
+   |                                                has type `&std::cell::Cell<&'2 &u32>`
 LL |         // Only works if 'x: 'y:
 LL |         demand_y(x, y, x.get())
    |         ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
index 73d39a8502b6438060cf366c70aad478c2dd4daa..37ea610397696823dc08c790414d86326b211735 100644 (file)
@@ -8,9 +8,9 @@ error: unsatisfied lifetime constraints
   --> $DIR/propagate-fail-to-approximate-longer-wrong-bounds.rs:51:9
    |
 LL |     establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {
-   |                                                ----------  ---------- lifetime `'2` appears in this argument
+   |                                                ----------  ---------- has type `&std::cell::Cell<&'2 &u32>`
    |                                                |
-   |                                                lifetime `'1` appears in this argument
+   |                                                has type `&std::cell::Cell<&'1 &u32>`
 LL |         // Only works if 'x: 'y:
 LL |         demand_y(x, y, x.get())
    |         ^^^^^^^^^^^^^^^^^^^^^^^ argument requires that `'1` must outlive `'2`
index d012dca25271c62af9e2a6ccd4fbfac91dd8bf9a..b0562711627387d59157493727b9bfe0681f784d 100644 (file)
@@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
   --> $DIR/region-lbr-named-does-not-outlive-static.rs:19:5
    |
 LL |     &*x
-   |     ^^^ free region requires that `'a` must outlive `'static`
+   |     ^^^ requires that `'a` must outlive `'static`
 
 error: aborting due to previous error
 
index 5724cdbd8c95be1fb5f557863315c69626baacdf..d6d1645ceeacc755a3b727c34dd40171d4a0019b 100644 (file)
@@ -8,10 +8,10 @@ error: unsatisfied lifetime constraints
   --> $DIR/return-wrong-bound-region.rs:21:23
    |
 LL |     expect_sig(|a, b| b); // ought to return `a`
-   |                 -  -  ^ free region requires that `'1` must outlive `'2`
+   |                 -  -  ^ closure was supposed to return data with lifetime `'1` but it is returning data with lifetime `'2`
    |                 |  |
-   |                 |  lifetime `'1` appears in this argument
-   |                 lifetime `'2` appears in this argument
+   |                 |  has type `&'1 i32`
+   |                 has type `&'2 i32`
 
 note: No external requirements
   --> $DIR/return-wrong-bound-region.rs:21:16
index 8acf2ef51ecd2ef65b4c0ef822f3ba0085251fcd..f12ab9b4f9602f8f9f326e088a5297933ab2b9b8 100644 (file)
@@ -1,11 +1,11 @@
-error: borrowed data escapes outside of closure
+error: borrowed data escapes outside of function
   --> $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 closure body
+   |                        - `s` is a reference that is only valid in the function body
 ...
 LL |     let _x = *s; //~ ERROR
-   |              ^^ `s` escapes the closure body here
+   |              ^^ `s` escapes the function body here
 
 error: aborting due to previous error
 
index 13f90e1f159d2091dc6da7692ff3983aa9853f39..d8f186a22324bbc06fc6d1d3155d3997633ca82d 100644 (file)
@@ -4,14 +4,14 @@ warning: not reporting region error due to nll
 LL |     let f: fn(_) -> _ = foo;
    |                         ^^^
 
-error: borrowed data escapes outside of closure
+error: borrowed data escapes outside of function
   --> $DIR/mir_check_cast_reify.rs:48:5
    |
 LL | fn bar<'a>(x: &'a u32) -> &'static u32 {
-   |            - `x` is a reference that is only valid in the closure body
+   |            - `x` is a reference that is only valid in the function body
 ...
 LL |     f(x)
-   |     ^^^^ `x` escapes the closure body here
+   |     ^^^^ `x` escapes the function body here
 
 error: aborting due to previous error
 
index b08c6f32e6b43bc460bac69353f59900a80c52cd..98c03e378147a7890bc55dae34df7c2f8a4903c7 100644 (file)
@@ -4,14 +4,14 @@ warning: not reporting region error due to nll
 LL |     let g: unsafe fn(_) -> _ = f;
    |                                ^
 
-error: borrowed data escapes outside of closure
+error: borrowed data escapes outside of function
   --> $DIR/mir_check_cast_unsafe_fn.rs:20:14
    |
 LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 {
-   |            ----- `input` is a reference that is only valid in the closure body
+   |            ----- `input` is a reference that is only valid in the function body
 ...
 LL |     unsafe { g(input) }
-   |              ^^^^^^^^ `input` escapes the closure body here
+   |              ^^^^^^^^ `input` escapes the function body here
 
 error: aborting due to previous error
 
index bb20678d4a11ba707fab252518638b751a84def9..83b2895e1d65d6ea866a090cca3202dbf9d7d8fc 100644 (file)
@@ -46,9 +46,9 @@
 
 static TARGETS: &'static [&'static str] = &[
     "aarch64-apple-ios",
+    "aarch64-fuchsia",
     "aarch64-linux-android",
     "aarch64-unknown-cloudabi",
-    "aarch64-unknown-fuchsia",
     "aarch64-unknown-linux-gnu",
     "aarch64-unknown-linux-musl",
     "arm-linux-androideabi",
     "wasm32-unknown-unknown",
     "x86_64-apple-darwin",
     "x86_64-apple-ios",
+    "x86_64-fuchsia",
     "x86_64-linux-android",
     "x86_64-pc-windows-gnu",
     "x86_64-pc-windows-msvc",
     "x86_64-sun-solaris",
     "x86_64-unknown-cloudabi",
     "x86_64-unknown-freebsd",
-    "x86_64-unknown-fuchsia",
     "x86_64-unknown-linux-gnu",
     "x86_64-unknown-linux-gnux32",
     "x86_64-unknown-linux-musl",
index eeb280e1de36cbd62f54dc9c981ba78bd96c0089..d77261f49597291024685a535ab2a2dee54f896c 100644 (file)
@@ -14,7 +14,7 @@
 use std::io::BufReader;
 use std::path::{Path, PathBuf};
 
-use common::{self, Config, Mode};
+use common::{self, CompareMode, Config, Mode};
 use util;
 
 use extract_gdb_version;
@@ -416,7 +416,7 @@ fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
     }
 }
 
-fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut FnMut(&str)) {
+fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
     if testfile.is_dir() {
         return;
     }
@@ -608,7 +608,12 @@ fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> bool {
                     common::DebugInfoLldb => name == "lldb",
                     common::Pretty => name == "pretty",
                     _ => false,
-                } || (self.target != self.host && name == "cross-compile")
+                } || (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,
+                }
         } else {
             false
         }
index 5bf898f5f1bafc3a637a59fb734e76ff123422a6..f056a041c13440c2ec748cbfa97975d96622745b 100644 (file)
@@ -21,7 +21,7 @@ mod imp {
     pub fn read2(
         out_pipe: ChildStdout,
         err_pipe: ChildStderr,
-        data: &mut FnMut(bool, &mut Vec<u8>, bool),
+        data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
     ) -> io::Result<()> {
         let mut buffer = Vec::new();
         out_pipe.read_to_end(&mut buffer)?;
@@ -45,7 +45,7 @@ mod imp {
     pub fn read2(
         mut out_pipe: ChildStdout,
         mut err_pipe: ChildStderr,
-        data: &mut FnMut(bool, &mut Vec<u8>, bool),
+        data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
     ) -> io::Result<()> {
         unsafe {
             libc::fcntl(out_pipe.as_raw_fd(), libc::F_SETFL, libc::O_NONBLOCK);
@@ -133,7 +133,7 @@ struct Pipe<'a> {
     pub fn read2(
         out_pipe: ChildStdout,
         err_pipe: ChildStderr,
-        data: &mut FnMut(bool, &mut Vec<u8>, bool),
+        data: &mut dyn FnMut(bool, &mut Vec<u8>, bool),
     ) -> io::Result<()> {
         let mut out = Vec::new();
         let mut err = Vec::new();
index ade7ae0a4aee768e2b731c7aa8487c1766690301..e72f90554d3c504bcc144b01f6cda4387912ac36 100644 (file)
@@ -44,18 +44,18 @@ fn from(format: &str) -> OutputFormat {
 }
 
 trait Formatter {
-    fn header(&self, output: &mut Write) -> Result<(), Box<Error>>;
-    fn title(&self, output: &mut Write) -> Result<(), Box<Error>>;
-    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
-                        err_code: &str) -> Result<(), Box<Error>>;
-    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>>;
+    fn header(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>>;
+    fn title(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>>;
+    fn error_code_block(&self, output: &mut dyn Write, info: &ErrorMetadata,
+                        err_code: &str) -> Result<(), Box<dyn Error>>;
+    fn footer(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>>;
 }
 
 struct HTMLFormatter;
 struct MarkdownFormatter;
 
 impl Formatter for HTMLFormatter {
-    fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
+    fn header(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>> {
         write!(output, r##"<!DOCTYPE html>
 <html>
 <head>
@@ -75,13 +75,13 @@ fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
         Ok(())
     }
 
-    fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
+    fn title(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>> {
         write!(output, "<h1>Rust Compiler Error Index</h1>\n")?;
         Ok(())
     }
 
-    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
-                        err_code: &str) -> Result<(), Box<Error>> {
+    fn error_code_block(&self, output: &mut dyn Write, info: &ErrorMetadata,
+                        err_code: &str) -> Result<(), Box<dyn Error>> {
         // Enclose each error in a div so they can be shown/hidden en masse.
         let desc_desc = match info.description {
             Some(_) => "error-described",
@@ -108,7 +108,7 @@ fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
         Ok(())
     }
 
-    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
+    fn footer(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>> {
         write!(output, r##"<script>
 function onEach(arr, func) {{
     if (arr && arr.length > 0 && func) {{
@@ -174,17 +174,17 @@ fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
 
 impl Formatter for MarkdownFormatter {
     #[allow(unused_variables)]
-    fn header(&self, output: &mut Write) -> Result<(), Box<Error>> {
+    fn header(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>> {
         Ok(())
     }
 
-    fn title(&self, output: &mut Write) -> Result<(), Box<Error>> {
+    fn title(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>> {
         write!(output, "# Rust Compiler Error Index\n")?;
         Ok(())
     }
 
-    fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
-                        err_code: &str) -> Result<(), Box<Error>> {
+    fn error_code_block(&self, output: &mut dyn Write, info: &ErrorMetadata,
+                        err_code: &str) -> Result<(), Box<dyn Error>> {
         Ok(match info.description {
             Some(ref desc) => write!(output, "## {}\n{}\n", err_code, desc)?,
             None => (),
@@ -192,13 +192,13 @@ fn error_code_block(&self, output: &mut Write, info: &ErrorMetadata,
     }
 
     #[allow(unused_variables)]
-    fn footer(&self, output: &mut Write) -> Result<(), Box<Error>> {
+    fn footer(&self, output: &mut dyn Write) -> Result<(), Box<dyn Error>> {
         Ok(())
     }
 }
 
 /// Load all the metadata files from `metadata_dir` into an in-memory map.
-fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<Error>> {
+fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<dyn Error>> {
     let mut all_errors = BTreeMap::new();
 
     for entry in read_dir(metadata_dir)? {
@@ -219,7 +219,7 @@ fn load_all_errors(metadata_dir: &Path) -> Result<ErrorMetadataMap, Box<Error>>
 
 /// Output an HTML page for the errors in `err_map` to `output_path`.
 fn render_error_page<T: Formatter>(err_map: &ErrorMetadataMap, output_path: &Path,
-                                   formatter: T) -> Result<(), Box<Error>> {
+                                   formatter: T) -> Result<(), Box<dyn Error>> {
     let mut output_file = File::create(output_path)?;
 
     formatter.header(&mut output_file)?;
@@ -232,7 +232,7 @@ fn render_error_page<T: Formatter>(err_map: &ErrorMetadataMap, output_path: &Pat
     formatter.footer(&mut output_file)
 }
 
-fn main_with_result(format: OutputFormat, dst: &Path) -> Result<(), Box<Error>> {
+fn main_with_result(format: OutputFormat, dst: &Path) -> Result<(), Box<dyn Error>> {
     let build_arch = env::var("CFG_BUILD")?;
     let metadata_dir = get_metadata_dir(&build_arch);
     let err_map = load_all_errors(&metadata_dir)?;
index 2f5275bb5be934671d4e70e84fde646a3f677cc4..011bf551140a010c9a634d5fac94d81bb70d18ee 100644 (file)
@@ -177,7 +177,7 @@ fn start_qemu_emulator(target: &str,
         _ => panic!("cannot start emulator for: {}"< target),
     }
 
-    fn add_files(w: &mut Write, root: &Path, cur: &Path) {
+    fn add_files(w: &mut dyn Write, root: &Path, cur: &Path) {
         for entry in t!(cur.read_dir()) {
             let entry = t!(entry);
             let path = entry.path();
@@ -297,7 +297,7 @@ fn run(files: String, args: Vec<String>) {
     }
 }
 
-fn send(path: &Path, dst: &mut Write) {
+fn send(path: &Path, dst: &mut dyn Write) {
     t!(dst.write_all(path.file_name().unwrap().to_str().unwrap().as_bytes()));
     t!(dst.write_all(&[0]));
     let mut file = t!(File::open(&path));
index ae13acd58bbc287b7f45206d8bf7f8802d6ede3d..5116f6662ff4dc416b15294b88d2bb9ffa39a114 100644 (file)
@@ -270,7 +270,7 @@ fn recv<B: BufRead>(dir: &Path, io: &mut B) -> PathBuf {
     return dst
 }
 
-fn my_copy(src: &mut Read, which: u8, dst: &Mutex<Write>) {
+fn my_copy(src: &mut dyn Read, which: u8, dst: &Mutex<dyn Write>) {
     let mut b = [0; 1024];
     loop {
         let n = t!(src.read(&mut b));
@@ -290,7 +290,7 @@ fn my_copy(src: &mut Read, which: u8, dst: &Mutex<Write>) {
     }
 }
 
-fn read_u32(r: &mut Read) -> u32 {
+fn read_u32(r: &mut dyn Read) -> u32 {
     let mut len = [0; 4];
     t!(r.read_exact(&mut len));
     ((len[0] as u32) << 24) |
index c9bc1b9d84970fac87bcc189024490ed4d63bd25..f68ba0b095bd0b72d253efc6de6680fb41cb9996 100644 (file)
@@ -334,7 +334,7 @@ fn get_and_check_lib_features(base_src_path: &Path,
 }
 
 fn map_lib_features(base_src_path: &Path,
-                    mf: &mut FnMut(Result<(&str, Feature), &str>, &Path, usize)) {
+                    mf: &mut dyn FnMut(Result<(&str, Feature), &str>, &Path, usize)) {
     let mut contents = String::new();
     super::walk(base_src_path,
                 &mut |path| super::filter_dirs(path) || path.ends_with("src/test"),
index 46217a4200967c90330a7670670c676b852d0b8f..bb041b39785ec661446824adc649c169dac191b1 100644 (file)
@@ -82,13 +82,13 @@ fn filter_dirs(path: &Path) -> bool {
     skip.iter().any(|p| path.ends_with(p))
 }
 
-fn walk_many(paths: &[&Path], skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
+fn walk_many(paths: &[&Path], skip: &mut dyn FnMut(&Path) -> bool, f: &mut dyn FnMut(&Path)) {
     for path in paths {
         walk(path, skip, f);
     }
 }
 
-fn walk(path: &Path, skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
+fn walk(path: &Path, skip: &mut dyn FnMut(&Path) -> bool, f: &mut dyn FnMut(&Path)) {
     for entry in t!(fs::read_dir(path), path) {
         let entry = t!(entry);
         let kind = t!(entry.file_type());