1
Fork 0

Auto merge of #52336 - ishitatsuyuki:dyn-rollup, r=Mark-Simulacrum

Rollup of bare_trait_objects PRs

All deny attributes were moved into bootstrap so they can be disabled with a line of config.

Warnings for external tools are allowed and it's up to the tool's maintainer to keep it warnings free.

r? @Mark-Simulacrum
cc @ljedrz @kennytm
This commit is contained in:
bors 2018-07-27 20:27:40 +00:00
commit 4f1e235744
112 changed files with 315 additions and 345 deletions

View file

@ -296,8 +296,10 @@ fn main() {
cmd.arg("--color=always"); 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("-Dwarnings");
cmd.arg("-Dbare_trait_objects");
} }
if verbose > 1 { if verbose > 1 {

View file

@ -12,7 +12,7 @@
use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot}; use compile::{run_cargo, std_cargo, test_cargo, rustc_cargo, rustc_cargo_env, add_to_sysroot};
use builder::{RunConfig, Builder, ShouldRun, Step}; use builder::{RunConfig, Builder, ShouldRun, Step};
use tool::{self, prepare_tool_cargo}; use tool::{self, prepare_tool_cargo, SourceType};
use {Compiler, Mode}; use {Compiler, Mode};
use cache::{INTERNER, Interned}; use cache::{INTERNER, Interned};
use std::path::PathBuf; use std::path::PathBuf;
@ -222,7 +222,8 @@ impl Step for Rustdoc {
Mode::ToolRustc, Mode::ToolRustc,
target, target,
"check", "check",
"src/tools/rustdoc"); "src/tools/rustdoc",
SourceType::InTree);
let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage)); let _folder = builder.fold_output(|| format!("stage{}-rustdoc", compiler.stage));
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target); println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);

View file

@ -28,7 +28,7 @@ use build_helper::up_to_date;
use util::symlink_dir; use util::symlink_dir;
use builder::{Builder, Compiler, RunConfig, ShouldRun, Step}; 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 compile;
use cache::{INTERNER, Interned}; use cache::{INTERNER, Interned};
use config::Config; use config::Config;
@ -814,6 +814,7 @@ impl Step for Rustdoc {
target, target,
"doc", "doc",
"src/tools/rustdoc", "src/tools/rustdoc",
SourceType::InTree,
); );
cargo.env("RUSTDOCFLAGS", "--document-private-items"); cargo.env("RUSTDOCFLAGS", "--document-private-items");

View file

@ -30,7 +30,7 @@ use compile;
use dist; use dist;
use flags::Subcommand; use flags::Subcommand;
use native; use native;
use tool::{self, Tool}; use tool::{self, Tool, SourceType};
use toolstate::ToolState; use toolstate::ToolState;
use util::{self, dylib_path, dylib_path_var}; use util::{self, dylib_path, dylib_path_var};
use Crate as CargoCrate; use Crate as CargoCrate;
@ -222,17 +222,18 @@ impl Step for Cargo {
compiler, compiler,
target: self.host, target: self.host,
}); });
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, self.host, "test"); let mut cargo = tool::prepare_tool_cargo(builder,
cargo compiler,
.arg("--manifest-path") Mode::ToolRustc,
.arg(builder.src.join("src/tools/cargo/Cargo.toml")); self.host,
"test",
"src/tools/cargo",
SourceType::Submodule);
if !builder.fail_fast { if !builder.fail_fast {
cargo.arg("--no-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 // Don't run cross-compile tests, we may not have cross-compiled libstd libs
// available. // available.
cargo.env("CFG_DISABLE_CROSS_TESTS", "1"); cargo.env("CFG_DISABLE_CROSS_TESTS", "1");
@ -286,10 +287,8 @@ impl Step for Rls {
Mode::ToolRustc, Mode::ToolRustc,
host, host,
"test", "test",
"src/tools/rls"); "src/tools/rls",
SourceType::Submodule);
// Don't build tests dynamically, just a pain to work with
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
builder.add_rustc_lib_path(compiler, &mut cargo); builder.add_rustc_lib_path(compiler, &mut cargo);
@ -341,10 +340,9 @@ impl Step for Rustfmt {
Mode::ToolRustc, Mode::ToolRustc,
host, host,
"test", "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); let dir = testdir(builder, compiler.host);
t!(fs::create_dir_all(&dir)); t!(fs::create_dir_all(&dir));
cargo.env("RUSTFMT_TEST_DIR", dir); cargo.env("RUSTFMT_TEST_DIR", dir);
@ -392,13 +390,14 @@ impl Step for Miri {
extra_features: Vec::new(), extra_features: Vec::new(),
}); });
if let Some(miri) = miri { if let Some(miri) = miri {
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test"); let mut cargo = tool::prepare_tool_cargo(builder,
cargo compiler,
.arg("--manifest-path") Mode::ToolRustc,
.arg(builder.src.join("src/tools/miri/Cargo.toml")); 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 // miri tests need to know about the stage sysroot
cargo.env("MIRI_SYSROOT", builder.sysroot(compiler)); cargo.env("MIRI_SYSROOT", builder.sysroot(compiler));
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
@ -450,13 +449,14 @@ impl Step for Clippy {
extra_features: Vec::new(), extra_features: Vec::new(),
}); });
if let Some(clippy) = clippy { if let Some(clippy) = clippy {
let mut cargo = builder.cargo(compiler, Mode::ToolRustc, host, "test"); let mut cargo = tool::prepare_tool_cargo(builder,
cargo compiler,
.arg("--manifest-path") Mode::ToolRustc,
.arg(builder.src.join("src/tools/clippy/Cargo.toml")); 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 // clippy tests need to know about the stage sysroot
cargo.env("SYSROOT", builder.sysroot(compiler)); cargo.env("SYSROOT", builder.sysroot(compiler));
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler)); cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
@ -1739,7 +1739,8 @@ impl Step for CrateRustdoc {
Mode::ToolRustc, Mode::ToolRustc,
target, target,
test_kind.subcommand(), test_kind.subcommand(),
"src/tools/rustdoc"); "src/tools/rustdoc",
SourceType::InTree);
if test_kind.subcommand() == "test" && !builder.fail_fast { if test_kind.subcommand() == "test" && !builder.fail_fast {
cargo.arg("--no-fail-fast"); cargo.arg("--no-fail-fast");
} }

View file

@ -75,6 +75,12 @@ impl Step for CleanTools {
} }
} }
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum SourceType {
InTree,
Submodule,
}
#[derive(Debug, Clone, Hash, PartialEq, Eq)] #[derive(Debug, Clone, Hash, PartialEq, Eq)]
struct ToolBuild { struct ToolBuild {
compiler: Compiler, compiler: Compiler,
@ -82,7 +88,8 @@ struct ToolBuild {
tool: &'static str, tool: &'static str,
path: &'static str, path: &'static str,
mode: Mode, mode: Mode,
is_ext_tool: bool, is_optional_tool: bool,
source_type: SourceType,
extra_features: Vec<String>, extra_features: Vec<String>,
} }
@ -102,7 +109,7 @@ impl Step for ToolBuild {
let target = self.target; let target = self.target;
let tool = self.tool; let tool = self.tool;
let path = self.path; let path = self.path;
let is_ext_tool = self.is_ext_tool; let is_optional_tool = self.is_optional_tool;
match self.mode { match self.mode {
Mode::ToolRustc => { Mode::ToolRustc => {
@ -115,7 +122,15 @@ impl Step for ToolBuild {
_ => panic!("unexpected Mode for tool build") _ => 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(" ")); cargo.arg("--features").arg(self.extra_features.join(" "));
let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool)); let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
@ -216,7 +231,7 @@ impl Step for ToolBuild {
}); });
if !is_expected { if !is_expected {
if !is_ext_tool { if !is_optional_tool {
exit(1); exit(1);
} else { } else {
return None; return None;
@ -238,6 +253,7 @@ pub fn prepare_tool_cargo(
target: Interned<String>, target: Interned<String>,
command: &'static str, command: &'static str,
path: &'static str, path: &'static str,
source_type: SourceType,
) -> Command { ) -> Command {
let mut cargo = builder.cargo(compiler, mode, target, command); let mut cargo = builder.cargo(compiler, mode, target, command);
let dir = builder.src.join(path); 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. // stages and such and it's just easier if they're not dynamically linked.
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); 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) { if let Some(dir) = builder.openssl_install_dir(target) {
cargo.env("OPENSSL_STATIC", "1"); cargo.env("OPENSSL_STATIC", "1");
cargo.env("OPENSSL_DIR", dir); cargo.env("OPENSSL_DIR", dir);
@ -274,7 +294,8 @@ pub fn prepare_tool_cargo(
} }
macro_rules! tool { 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)] #[derive(Copy, PartialEq, Eq, Clone)]
pub enum Tool { pub enum Tool {
$( $(
@ -351,7 +372,12 @@ macro_rules! tool {
tool: $tool_name, tool: $tool_name,
mode: $mode, mode: $mode,
path: $path, path: $path,
is_ext_tool: false, is_optional_tool: false,
source_type: if false $(|| $external)* {
SourceType::Submodule
} else {
SourceType::InTree
},
extra_features: Vec::new(), extra_features: Vec::new(),
}).expect("expected to build -- essential tool") }).expect("expected to build -- essential tool")
} }
@ -370,7 +396,8 @@ tool!(
Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true; Compiletest, "src/tools/compiletest", "compiletest", Mode::ToolBootstrap, llvm_tools = true;
BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap; BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::ToolBootstrap;
RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", 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; RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::ToolBootstrap;
); );
@ -401,7 +428,8 @@ impl Step for RemoteTestServer {
tool: "remote-test-server", tool: "remote-test-server",
mode: Mode::ToolStd, mode: Mode::ToolStd,
path: "src/tools/remote-test-server", path: "src/tools/remote-test-server",
is_ext_tool: false, is_optional_tool: false,
source_type: SourceType::InTree,
extra_features: Vec::new(), extra_features: Vec::new(),
}).expect("expected to build -- essential tool") }).expect("expected to build -- essential tool")
} }
@ -449,12 +477,15 @@ impl Step for Rustdoc {
target: builder.config.build, target: builder.config.build,
}); });
let mut cargo = prepare_tool_cargo(builder, let mut cargo = prepare_tool_cargo(
build_compiler, builder,
Mode::ToolRustc, build_compiler,
target, Mode::ToolRustc,
"build", target,
"src/tools/rustdoc"); "build",
"src/tools/rustdoc",
SourceType::InTree,
);
// Most tools don't get debuginfo, but rustdoc should. // Most tools don't get debuginfo, but rustdoc should.
cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string()) cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string())
@ -525,7 +556,8 @@ impl Step for Cargo {
tool: "cargo", tool: "cargo",
mode: Mode::ToolRustc, mode: Mode::ToolRustc,
path: "src/tools/cargo", path: "src/tools/cargo",
is_ext_tool: false, is_optional_tool: false,
source_type: SourceType::Submodule,
extra_features: Vec::new(), extra_features: Vec::new(),
}).expect("expected to build -- essential tool") }).expect("expected to build -- essential tool")
} }
@ -574,7 +606,8 @@ macro_rules! tool_extended {
mode: Mode::ToolRustc, mode: Mode::ToolRustc,
path: $path, path: $path,
extra_features: $sel.extra_features, extra_features: $sel.extra_features,
is_ext_tool: true, is_optional_tool: true,
source_type: SourceType::Submodule,
}) })
} }
} }

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![deny(bare_trait_objects)]
use std::fs::File; use std::fs::File;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};

View file

@ -72,7 +72,6 @@
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
#![no_std] #![no_std]
#![needs_allocator] #![needs_allocator]
#![deny(bare_trait_objects)]
#![deny(missing_debug_implementations)] #![deny(missing_debug_implementations)]
#![cfg_attr(test, allow(deprecated))] // rand #![cfg_attr(test, allow(deprecated))] // rand

View file

@ -18,7 +18,7 @@ fn uninhabited() {
a = a.clone(); a = a.clone();
assert!(a.upgrade().is_none()); assert!(a.upgrade().is_none());
let mut a: Weak<Any> = a; // Unsizing let mut a: Weak<dyn Any> = a; // Unsizing
a = a.clone(); a = a.clone();
assert!(a.upgrade().is_none()); assert!(a.upgrade().is_none());
} }
@ -39,7 +39,7 @@ fn slice() {
#[test] #[test]
fn trait_object() { fn trait_object() {
let a: Arc<u32> = Arc::new(4); 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 // Exercise is_dangling() with a DST
let mut a = Arc::downgrade(&a); let mut a = Arc::downgrade(&a);
@ -49,7 +49,7 @@ fn trait_object() {
let mut b = Weak::<u32>::new(); let mut b = Weak::<u32>::new();
b = b.clone(); b = b.clone();
assert!(b.upgrade().is_none()); assert!(b.upgrade().is_none());
let mut b: Weak<Any> = b; // Unsizing let mut b: Weak<dyn Any> = b; // Unsizing
b = b.clone(); b = b.clone();
assert!(b.upgrade().is_none()); assert!(b.upgrade().is_none());
} }

View file

@ -40,7 +40,7 @@ fn test_hash() {
} }
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F) 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_a = BTreeSet::new();
let mut set_b = BTreeSet::new(); let mut set_b = BTreeSet::new();

View file

@ -63,7 +63,7 @@ fn test_boxed_hasher() {
5u32.hash(&mut hasher_1); 5u32.hash(&mut hasher_1);
assert_eq!(ordinary_hash, hasher_1.finish()); 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); 5u32.hash(&mut hasher_2);
assert_eq!(ordinary_hash, hasher_2.finish()); assert_eq!(ordinary_hash, hasher_2.finish());
} }

View file

@ -18,7 +18,7 @@ fn uninhabited() {
a = a.clone(); a = a.clone();
assert!(a.upgrade().is_none()); assert!(a.upgrade().is_none());
let mut a: Weak<Any> = a; // Unsizing let mut a: Weak<dyn Any> = a; // Unsizing
a = a.clone(); a = a.clone();
assert!(a.upgrade().is_none()); assert!(a.upgrade().is_none());
} }
@ -39,7 +39,7 @@ fn slice() {
#[test] #[test]
fn trait_object() { fn trait_object() {
let a: Rc<u32> = Rc::new(4); 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 // Exercise is_dangling() with a DST
let mut a = Rc::downgrade(&a); let mut a = Rc::downgrade(&a);
@ -49,7 +49,7 @@ fn trait_object() {
let mut b = Weak::<u32>::new(); let mut b = Weak::<u32>::new();
b = b.clone(); b = b.clone();
assert!(b.upgrade().is_none()); assert!(b.upgrade().is_none());
let mut b: Weak<Any> = b; // Unsizing let mut b: Weak<dyn Any> = b; // Unsizing
b = b.clone(); b = b.clone();
assert!(b.upgrade().is_none()); assert!(b.upgrade().is_none());
} }

View file

@ -10,7 +10,6 @@
#![no_std] #![no_std]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![unstable(feature = "alloc_jemalloc", #![unstable(feature = "alloc_jemalloc",
reason = "implementation detail of std, does not provide any public API", reason = "implementation detail of std, does not provide any public API",
issue = "0")] issue = "0")]

View file

@ -10,7 +10,6 @@
#![no_std] #![no_std]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![unstable(feature = "alloc_system", #![unstable(feature = "alloc_system",
reason = "this library is unlikely to be stabilized in its current \ reason = "this library is unlikely to be stabilized in its current \
form or name", form or name",

View file

@ -30,7 +30,6 @@
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]
#![allow(deprecated)] #![allow(deprecated)]
#![deny(bare_trait_objects)]
extern crate alloc; extern crate alloc;
extern crate rustc_data_structures; extern crate rustc_data_structures;

View file

@ -120,7 +120,7 @@ impl<T: 'static + ?Sized > Any for T {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#[stable(feature = "rust1", since = "1.0.0")] #[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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("Any") f.pad("Any")
} }
@ -130,20 +130,20 @@ impl fmt::Debug for Any {
// hence used with `unwrap`. May eventually no longer be needed if // hence used with `unwrap`. May eventually no longer be needed if
// dispatch works with upcasting. // dispatch works with upcasting.
#[stable(feature = "rust1", since = "1.0.0")] #[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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("Any") f.pad("Any")
} }
} }
#[stable(feature = "any_send_sync_methods", since = "1.28.0")] #[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 { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("Any") f.pad("Any")
} }
} }
impl Any { impl dyn Any {
/// Returns `true` if the boxed type is the same as `T`. /// Returns `true` if the boxed type is the same as `T`.
/// ///
/// # Examples /// # Examples
@ -203,7 +203,7 @@ impl Any {
pub fn downcast_ref<T: Any>(&self) -> Option<&T> { pub fn downcast_ref<T: Any>(&self) -> Option<&T> {
if self.is::<T>() { if self.is::<T>() {
unsafe { unsafe {
Some(&*(self as *const Any as *const T)) Some(&*(self as *const dyn Any as *const T))
} }
} else { } else {
None None
@ -240,7 +240,7 @@ impl Any {
pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> { pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> {
if self.is::<T>() { if self.is::<T>() {
unsafe { unsafe {
Some(&mut *(self as *mut Any as *mut T)) Some(&mut *(self as *mut dyn Any as *mut T))
} }
} else { } else {
None None
@ -248,7 +248,7 @@ impl Any {
} }
} }
impl Any+Send { impl dyn Any+Send {
/// Forwards to the method defined on the type `Any`. /// Forwards to the method defined on the type `Any`.
/// ///
/// # Examples /// # Examples
@ -332,7 +332,7 @@ impl Any+Send {
} }
} }
impl Any+Send+Sync { impl dyn Any+Send+Sync {
/// Forwards to the method defined on the type `Any`. /// Forwards to the method defined on the type `Any`.
/// ///
/// # Examples /// # Examples

View file

@ -1532,7 +1532,7 @@ impl<T: CoerceUnsized<U>, U> CoerceUnsized<UnsafeCell<U>> for UnsafeCell<T> {}
#[allow(unused)] #[allow(unused)]
fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) { fn assert_coerce_unsized(a: UnsafeCell<&i32>, b: Cell<&i32>, c: RefCell<&i32>) {
let _: UnsafeCell<&Send> = a; let _: UnsafeCell<&dyn Send> = a;
let _: Cell<&Send> = b; let _: Cell<&dyn Send> = b;
let _: RefCell<&Send> = c; let _: RefCell<&dyn Send> = c;
} }

View file

@ -11,7 +11,7 @@
use fmt; use fmt;
struct PadAdapter<'a> { struct PadAdapter<'a> {
buf: &'a mut (fmt::Write + 'a), buf: &'a mut (dyn fmt::Write + 'a),
on_newline: bool, 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> { impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
/// Adds a new field to the generated struct output. /// Adds a new field to the generated struct output.
#[stable(feature = "debug_builders", since = "1.2.0")] #[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(|_| { self.result = self.result.and_then(|_| {
let prefix = if self.has_fields { 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> { impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
/// Adds a new field to the generated tuple struct output. /// Adds a new field to the generated tuple struct output.
#[stable(feature = "debug_builders", since = "1.2.0")] #[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(|_| { self.result = self.result.and_then(|_| {
let (prefix, space) = if self.fields > 0 { let (prefix, space) = if self.fields > 0 {
(",", " ") (",", " ")
@ -258,7 +258,7 @@ struct DebugInner<'a, 'b: 'a> {
} }
impl<'a, 'b: 'a> DebugInner<'a, 'b> { 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(|_| { self.result = self.result.and_then(|_| {
if self.is_pretty() { if self.is_pretty() {
let mut slot = None; 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> { impl<'a, 'b: 'a> DebugSet<'a, 'b> {
/// Adds a new entry to the set output. /// Adds a new entry to the set output.
#[stable(feature = "debug_builders", since = "1.2.0")] #[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.inner.entry(entry);
self 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> { impl<'a, 'b: 'a> DebugList<'a, 'b> {
/// Adds a new entry to the list output. /// Adds a new entry to the list output.
#[stable(feature = "debug_builders", since = "1.2.0")] #[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.inner.entry(entry);
self 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> { impl<'a, 'b: 'a> DebugMap<'a, 'b> {
/// Adds a new entry to the map output. /// Adds a new entry to the map output.
#[stable(feature = "debug_builders", since = "1.2.0")] #[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(|_| { self.result = self.result.and_then(|_| {
if self.is_pretty() { if self.is_pretty() {
let mut slot = None; let mut slot = None;

View file

@ -255,7 +255,7 @@ pub struct Formatter<'a> {
width: Option<usize>, width: Option<usize>,
precision: Option<usize>, precision: Option<usize>,
buf: &'a mut (Write+'a), buf: &'a mut (dyn Write+'a),
curarg: slice::Iter<'a, ArgumentV1<'a>>, curarg: slice::Iter<'a, ArgumentV1<'a>>,
args: &'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` /// It was added after #45197 showed that one could share a `!Sync`
/// object across threads by passing it into `format_args!`. /// 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 /// This struct represents the generic "argument" which is taken by the Xprintf
@ -1020,7 +1020,7 @@ pub trait UpperExp {
/// ///
/// [`write!`]: ../../std/macro.write.html /// [`write!`]: ../../std/macro.write.html
#[stable(feature = "rust1", since = "1.0.0")] #[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 { let mut formatter = Formatter {
flags: 0, flags: 0,
width: None, width: None,
@ -1062,7 +1062,7 @@ pub fn write(output: &mut Write, args: Arguments) -> Result {
impl<'a> Formatter<'a> { impl<'a> Formatter<'a> {
fn wrap_buf<'b, 'c, F>(&'b mut self, wrap: F) -> Formatter<'c> 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 { Formatter {
// We want to change this // We want to change this
@ -1342,7 +1342,7 @@ impl<'a> Formatter<'a> {
} }
fn write_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) }) buf.write_str(unsafe { str::from_utf8_unchecked(s) })
} }

View file

@ -18,7 +18,7 @@ use super::{Inspect, Map, Peekable, Scan, Skip, SkipWhile, StepBy, Take, TakeWhi
use super::{Zip, Sum, Product}; use super::{Zip, Sum, Product};
use super::{ChainState, FromIterator, ZipImpl}; 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. /// An interface for dealing with iterators.
/// ///

View file

@ -43,7 +43,7 @@ use fmt;
#[stable(feature = "panic_hooks", since = "1.10.0")] #[stable(feature = "panic_hooks", since = "1.10.0")]
#[derive(Debug)] #[derive(Debug)]
pub struct PanicInfo<'a> { pub struct PanicInfo<'a> {
payload: &'a (Any + Send), payload: &'a (dyn Any + Send),
message: Option<&'a fmt::Arguments<'a>>, message: Option<&'a fmt::Arguments<'a>>,
location: Location<'a>, location: Location<'a>,
} }
@ -64,7 +64,7 @@ impl<'a> PanicInfo<'a> {
#[doc(hidden)] #[doc(hidden)]
#[inline] #[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; self.payload = info;
} }
@ -86,7 +86,7 @@ impl<'a> PanicInfo<'a> {
/// panic!("Normal panic"); /// panic!("Normal panic");
/// ``` /// ```
#[stable(feature = "panic_hooks", since = "1.10.0")] #[stable(feature = "panic_hooks", since = "1.10.0")]
pub fn payload(&self) -> &(Any + Send) { pub fn payload(&self) -> &(dyn Any + Send) {
self.payload self.payload
} }
@ -270,6 +270,6 @@ impl<'a> fmt::Display for Location<'a> {
#[unstable(feature = "std_internals", issue = "0")] #[unstable(feature = "std_internals", issue = "0")]
#[doc(hidden)] #[doc(hidden)]
pub unsafe trait BoxMeUp { pub unsafe trait BoxMeUp {
fn box_me_up(&mut self) -> *mut (Any + Send); fn box_me_up(&mut self) -> *mut (dyn Any + Send);
fn get(&mut self) -> &(Any + Send); fn get(&mut self) -> &(dyn Any + Send);
} }

View file

@ -21,7 +21,7 @@ use super::{Executor, Waker, LocalWaker};
/// when performing a single `poll` step on a task. /// when performing a single `poll` step on a task.
pub struct Context<'a> { pub struct Context<'a> {
local_waker: &'a LocalWaker, local_waker: &'a LocalWaker,
executor: &'a mut Executor, executor: &'a mut dyn Executor,
} }
impl<'a> fmt::Debug for Context<'a> { impl<'a> fmt::Debug for Context<'a> {
@ -34,7 +34,7 @@ impl<'a> fmt::Debug for Context<'a> {
impl<'a> Context<'a> { impl<'a> Context<'a> {
/// Create a new task `Context` with the provided `local_waker`, `waker`, and `executor`. /// Create a new task `Context` with the provided `local_waker`, `waker`, and `executor`.
#[inline] #[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 { Context {
local_waker, local_waker,
executor, executor,
@ -58,7 +58,7 @@ impl<'a> Context<'a> {
/// This method is useful primarily if you want to explicitly handle /// This method is useful primarily if you want to explicitly handle
/// spawn failures. /// spawn failures.
#[inline] #[inline]
pub fn executor(&mut self) -> &mut Executor { pub fn executor(&mut self) -> &mut dyn Executor {
self.executor self.executor
} }

View file

@ -23,7 +23,7 @@ use ptr::NonNull;
/// trait, allowing notifications to get routed through it. /// trait, allowing notifications to get routed through it.
#[repr(transparent)] #[repr(transparent)]
pub struct Waker { pub struct Waker {
inner: NonNull<UnsafeWake>, inner: NonNull<dyn UnsafeWake>,
} }
impl Unpin for Waker {} impl Unpin for Waker {}
@ -41,7 +41,7 @@ impl Waker {
/// use the `Waker::from` function instead which works with the safe /// use the `Waker::from` function instead which works with the safe
/// `Arc` type and the safe `Wake` trait. /// `Arc` type and the safe `Wake` trait.
#[inline] #[inline]
pub unsafe fn new(inner: NonNull<UnsafeWake>) -> Self { pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
Waker { inner: inner } Waker { inner: inner }
} }
@ -98,7 +98,7 @@ impl Drop for Waker {
/// behavior. /// behavior.
#[repr(transparent)] #[repr(transparent)]
pub struct LocalWaker { pub struct LocalWaker {
inner: NonNull<UnsafeWake>, inner: NonNull<dyn UnsafeWake>,
} }
impl Unpin for LocalWaker {} 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()` /// For this function to be used safely, it must be sound to call `inner.wake_local()`
/// on the current thread. /// on the current thread.
#[inline] #[inline]
pub unsafe fn new(inner: NonNull<UnsafeWake>) -> Self { pub unsafe fn new(inner: NonNull<dyn UnsafeWake>) -> Self {
LocalWaker { inner: inner } LocalWaker { inner: inner }
} }

View file

@ -17,7 +17,7 @@ static TEST: &'static str = "Test";
#[test] #[test]
fn any_referenced() { 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!(a.is::<i32>());
assert!(!b.is::<i32>()); assert!(!b.is::<i32>());
@ -34,7 +34,11 @@ fn any_referenced() {
#[test] #[test]
fn any_owning() { 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!(a.is::<usize>());
assert!(!b.is::<usize>()); assert!(!b.is::<usize>());
@ -51,7 +55,7 @@ fn any_owning() {
#[test] #[test]
fn any_downcast_ref() { fn any_downcast_ref() {
let a = &5_usize as &Any; let a = &5_usize as &dyn Any;
match a.downcast_ref::<usize>() { match a.downcast_ref::<usize>() {
Some(&5) => {} Some(&5) => {}
@ -69,9 +73,9 @@ fn any_downcast_mut() {
let mut a = 5_usize; let mut a = 5_usize;
let mut b: Box<_> = box 7_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 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>() { match a_r.downcast_mut::<usize>() {
Some(x) => { Some(x) => {
@ -113,7 +117,7 @@ fn any_downcast_mut() {
#[test] #[test]
fn any_fixed_vec() { fn any_fixed_vec() {
let test = [0_usize; 8]; 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; 8]>());
assert!(!test.is::<[usize; 10]>()); assert!(!test.is::<[usize; 10]>());
} }

View file

@ -128,7 +128,7 @@ fn test_custom_state() {
fn test_indirect_hasher() { fn test_indirect_hasher() {
let mut hasher = MyHasher { hash: 0 }; 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); 5u32.hash(&mut indirect_hasher);
} }
assert_eq!(hasher.hash, 5); assert_eq!(hasher.hash, 5);

View file

@ -22,7 +22,7 @@ fn test_typeid_sized_types() {
#[test] #[test]
fn test_typeid_unsized_types() { fn test_typeid_unsized_types() {
trait Z {} 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::<X>(), TypeId::of::<X>());
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>()); assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());

View file

@ -109,11 +109,11 @@ fn test_transmute() {
trait Foo { fn dummy(&self) { } } trait Foo { fn dummy(&self) { } }
impl Foo for isize {} impl Foo for isize {}
let a = box 100isize as Box<Foo>; let a = box 100isize as Box<dyn Foo>;
unsafe { unsafe {
let x: ::core::raw::TraitObject = transmute(a); let x: ::core::raw::TraitObject = transmute(a);
assert!(*(x.data as *const isize) == 100); assert!(*(x.data as *const isize) == 100);
let _x: Box<Foo> = transmute(x); let _x: Box<dyn Foo> = transmute(x);
} }
unsafe { unsafe {

View file

@ -240,7 +240,7 @@ fn test_collect() {
assert!(v == None); assert!(v == None);
// test that it does not take more elements than it needs // 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!()]; [box || Some(()), box || None, box || panic!()];
let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect(); let v: Option<Vec<()>> = functions.iter_mut().map(|f| (*f)()).collect();

View file

@ -84,16 +84,16 @@ fn test_is_null() {
assert!(nms.is_null()); assert!(nms.is_null());
// Pointers to unsized types -- trait objects // Pointers to unsized types -- trait objects
let ci: *const ToString = &3; let ci: *const dyn ToString = &3;
assert!(!ci.is_null()); assert!(!ci.is_null());
let mi: *mut ToString = &mut 3; let mi: *mut dyn ToString = &mut 3;
assert!(!mi.is_null()); assert!(!mi.is_null());
let nci: *const ToString = null::<isize>(); let nci: *const dyn ToString = null::<isize>();
assert!(nci.is_null()); assert!(nci.is_null());
let nmi: *mut ToString = null_mut::<isize>(); let nmi: *mut dyn ToString = null_mut::<isize>();
assert!(nmi.is_null()); assert!(nmi.is_null());
} }
@ -140,16 +140,16 @@ fn test_as_ref() {
assert_eq!(nms.as_ref(), None); assert_eq!(nms.as_ref(), None);
// Pointers to unsized types -- trait objects // Pointers to unsized types -- trait objects
let ci: *const ToString = &3; let ci: *const dyn ToString = &3;
assert!(ci.as_ref().is_some()); 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()); 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()); 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()); assert!(nmi.as_ref().is_none());
} }
} }
@ -182,10 +182,10 @@ fn test_as_mut() {
assert_eq!(nms.as_mut(), None); assert_eq!(nms.as_mut(), None);
// Pointers to unsized types -- trait objects // 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()); 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()); assert!(nmi.as_mut().is_none());
} }
} }

View file

@ -81,7 +81,7 @@ fn test_collect() {
assert!(v == Err(2)); assert!(v == Err(2));
// test that it does not take more elements than it needs // 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!()]; [box || Ok(()), box || Err(1), box || panic!()];
let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect(); let v: Result<Vec<()>, isize> = functions.iter_mut().map(|f| (*f)()).collect();

View file

@ -14,8 +14,6 @@
//! Parsing does not happen at runtime: structures of `std::fmt::rt` are //! Parsing does not happen at runtime: structures of `std::fmt::rt` are
//! generated instead. //! generated instead.
#![deny(bare_trait_objects)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/", html_root_url = "https://doc.rust-lang.org/nightly/",

View file

@ -283,8 +283,6 @@
//! //!
//! * [DOT language](http://www.graphviz.org/doc/info/lang.html) //! * [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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/", html_root_url = "https://doc.rust-lang.org/nightly/",

View file

@ -21,7 +21,6 @@
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![panic_runtime] #![panic_runtime]
#![allow(unused_features)] #![allow(unused_features)]
#![deny(bare_trait_objects)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(libc)] #![feature(libc)]

View file

@ -22,7 +22,6 @@
//! More documentation about each implementation can be found in the respective //! More documentation about each implementation can be found in the respective
//! module. //! module.
#![deny(bare_trait_objects)]
#![no_std] #![no_std]
#![unstable(feature = "panic_unwind", issue = "32837")] #![unstable(feature = "panic_unwind", issue = "32837")]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",

View file

@ -22,7 +22,6 @@
//! See [the book](../book/first-edition/procedural-macros.html) for more. //! See [the book](../book/first-edition/procedural-macros.html) for more.
#![stable(feature = "proc_macro_lib", since = "1.15.0")] #![stable(feature = "proc_macro_lib", since = "1.15.0")]
#![deny(bare_trait_objects)]
#![deny(missing_docs)] #![deny(missing_docs)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",

View file

@ -15,5 +15,4 @@
reason = "internal implementation detail of rustc right now", reason = "internal implementation detail of rustc right now",
issue = "0")] issue = "0")]
#![allow(unused_features)] #![allow(unused_features)]
#![deny(bare_trait_objects)]
#![feature(staged_api)] #![feature(staged_api)]

View file

@ -36,8 +36,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![deny(bare_trait_objects)]
#![feature(rustc_private)] #![feature(rustc_private)]
#[macro_use] extern crate log; #[macro_use] extern crate log;

View file

@ -40,8 +40,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![deny(bare_trait_objects)]
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]

View file

@ -13,7 +13,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![deny(bare_trait_objects)]
#![feature(from_ref)] #![feature(from_ref)]
#![feature(quote)] #![feature(quote)]

View file

@ -23,7 +23,6 @@
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![feature(fs_read_write)] #![feature(fs_read_write)]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![feature(libc)] #![feature(libc)]
#![feature(quote)] #![feature(quote)]
#![feature(range_contains)] #![feature(range_contains)]

View file

@ -20,7 +20,6 @@
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![feature(quote)] #![feature(quote)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]

View file

@ -16,8 +16,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -14,8 +14,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -10,8 +10,6 @@
//! Support for serializing the dep-graph and reloading it. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -19,8 +19,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -12,7 +12,6 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![allow(dead_code)] #![allow(dead_code)]
#![deny(bare_trait_objects)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![deny(bare_trait_objects)]
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -14,8 +14,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
*/ */
#![deny(bare_trait_objects)]
#![feature(slice_patterns)] #![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)] #![feature(slice_sort_by_cached_key)]
#![feature(from_ref)] #![feature(from_ref)]

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![deny(bare_trait_objects)]
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]

View file

@ -14,8 +14,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -9,7 +9,6 @@
// except according to those terms. // except according to those terms.
#![allow(bad_style)] #![allow(bad_style)]
#![deny(bare_trait_objects)]
pub struct Intrinsic { pub struct Intrinsic {
pub inputs: &'static [&'static Type], pub inputs: &'static [&'static Type],

View file

@ -60,8 +60,6 @@
//! See the [`plugin` feature](../unstable-book/language-features/plugin.html) of //! See the [`plugin` feature](../unstable-book/language-features/plugin.html) of
//! the Unstable Book for more examples. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -13,7 +13,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![deny(bare_trait_objects)]
#![recursion_limit="256"] #![recursion_limit="256"]

View file

@ -21,8 +21,6 @@
//! one that doesn't; the one that doesn't might get decent parallel //! one that doesn't; the one that doesn't might get decent parallel
//! build speedups. //! build speedups.
#![deny(bare_trait_objects)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -11,8 +11,6 @@
//! New recursive solver modeled on Chalk's recursive solver. Most of //! New recursive solver modeled on Chalk's recursive solver. Most of
//! the guts are broken up into modules; see the comments in those modules. //! the guts are broken up into modules; see the comments in those modules.
#![deny(bare_trait_objects)]
#![feature(crate_in_paths)] #![feature(crate_in_paths)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(extern_prelude)] #![feature(extern_prelude)]

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![deny(bare_trait_objects)]
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]

View file

@ -70,7 +70,6 @@ This API is completely unstable and subject to change.
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![deny(bare_trait_objects)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]

View file

@ -375,7 +375,7 @@ impl fmt::Debug for Item {
let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate) let fake = MAX_DEF_ID.with(|m| m.borrow().get(&self.def_id.krate)
.map(|id| self.def_id >= *id).unwrap_or(false)); .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") fmt.debug_struct("Item")
.field("source", &self.source) .field("source", &self.source)

View file

@ -55,7 +55,7 @@ pub struct DocContext<'a, 'tcx: 'a, 'rcx: 'a> {
/// The stack of module NodeIds up till this point /// The stack of module NodeIds up till this point
pub mod_ids: RefCell<Vec<NodeId>>, pub mod_ids: RefCell<Vec<NodeId>>,
pub crate_name: Option<String>, pub crate_name: Option<String>,
pub cstore: Rc<CrateStore>, pub cstore: Rc<dyn CrateStore>,
pub populated_all_crate_impls: Cell<bool>, pub populated_all_crate_impls: Cell<bool>,
// Note that external items for which `doc(hidden)` applies to are shown as // 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 // non-reachable while local items aren't. This is because we're reusing

View file

@ -395,7 +395,7 @@ impl Class {
fn write_header(class: Option<&str>, fn write_header(class: Option<&str>,
id: Option<&str>, id: Option<&str>,
out: &mut Write) out: &mut dyn Write)
-> io::Result<()> { -> io::Result<()> {
write!(out, "<pre ")?; write!(out, "<pre ")?;
if let Some(id) = id { if let Some(id) = id {
@ -404,6 +404,6 @@ fn write_header(class: Option<&str>,
write!(out, "class=\"rust {}\">\n", class.unwrap_or("")) 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") write!(out, "</pre>\n")
} }

View file

@ -32,7 +32,7 @@ pub struct Page<'a> {
} }
pub fn render<T: fmt::Display, S: fmt::Display>( 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]) css_file_extension: bool, themes: &[PathBuf])
-> io::Result<()> -> 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. // <script> triggers a redirect before refresh, so this is fine.
write!(dst, write!(dst,
r##"<!DOCTYPE html> r##"<!DOCTYPE html>

View file

@ -1822,7 +1822,7 @@ impl Context {
} }
fn render_item(&self, fn render_item(&self,
writer: &mut io::Write, writer: &mut dyn io::Write,
it: &clean::Item, it: &clean::Item,
pushname: bool) pushname: bool)
-> io::Result<()> { -> io::Result<()> {

View file

@ -249,7 +249,7 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize,
} }
fn flush(&mut self) -> io::Result<()> { Ok(()) } 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 { impl Drop for Bomb {
fn drop(&mut self) { fn drop(&mut self) {
let _ = self.1.write_all(&self.0.lock().unwrap()); let _ = self.1.write_all(&self.0.lock().unwrap());

View file

@ -14,8 +14,6 @@
Core encoding and decoding interfaces. 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/", html_root_url = "https://doc.rust-lang.org/nightly/",

View file

@ -138,7 +138,7 @@ pub trait Error: Debug + Display {
/// } /// }
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[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` /// Get the `TypeId` of `self`
#[doc(hidden)] #[doc(hidden)]
@ -151,22 +151,22 @@ pub trait Error: Debug + Display {
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, E: Error + 'a> From<E> for Box<Error + 'a> { impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
fn from(err: E) -> Box<Error + 'a> { fn from(err: E) -> Box<dyn Error + 'a> {
Box::new(err) Box::new(err)
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, E: Error + Send + Sync + 'a> From<E> for 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<Error + Send + Sync + 'a> { fn from(err: E) -> Box<dyn Error + Send + Sync + 'a> {
Box::new(err) Box::new(err)
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl From<String> for Box<Error + Send + Sync> { impl From<String> for Box<dyn Error + Send + Sync> {
fn from(err: String) -> Box<Error + Send + Sync> { fn from(err: String) -> Box<dyn Error + Send + Sync> {
#[derive(Debug)] #[derive(Debug)]
struct StringError(String); struct StringError(String);
@ -185,38 +185,38 @@ impl From<String> for Box<Error + Send + Sync> {
} }
#[stable(feature = "string_box_error", since = "1.6.0")] #[stable(feature = "string_box_error", since = "1.6.0")]
impl From<String> for Box<Error> { impl From<String> for Box<dyn Error> {
fn from(str_err: String) -> Box<Error> { fn from(str_err: String) -> Box<dyn Error> {
let err1: Box<Error + Send + Sync> = From::from(str_err); let err1: Box<dyn Error + Send + Sync> = From::from(str_err);
let err2: Box<Error> = err1; let err2: Box<dyn Error> = err1;
err2 err2
} }
} }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a> { impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
fn from(err: &'b str) -> Box<Error + Send + Sync + 'a> { fn from(err: &'b str) -> Box<dyn Error + Send + Sync + 'a> {
From::from(String::from(err)) From::from(String::from(err))
} }
} }
#[stable(feature = "string_box_error", since = "1.6.0")] #[stable(feature = "string_box_error", since = "1.6.0")]
impl<'a> From<&'a str> for Box<Error> { impl<'a> From<&'a str> for Box<dyn Error> {
fn from(err: &'a str) -> Box<Error> { fn from(err: &'a str) -> Box<dyn Error> {
From::from(String::from(err)) From::from(String::from(err))
} }
} }
#[stable(feature = "cow_box_error", since = "1.22.0")] #[stable(feature = "cow_box_error", since = "1.22.0")]
impl<'a, 'b> From<Cow<'b, str>> for 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<Error + Send + Sync + 'a> { fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a> {
From::from(String::from(err)) From::from(String::from(err))
} }
} }
#[stable(feature = "cow_box_error", since = "1.22.0")] #[stable(feature = "cow_box_error", since = "1.22.0")]
impl<'a> From<Cow<'a, str>> for Box<Error> { impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
fn from(err: Cow<'a, str>) -> Box<Error> { fn from(err: Cow<'a, str>) -> Box<dyn Error> {
From::from(String::from(err)) From::from(String::from(err))
} }
} }
@ -327,7 +327,7 @@ impl<T: Error> Error for Box<T> {
Error::description(&**self) Error::description(&**self)
} }
fn cause(&self) -> Option<&Error> { fn cause(&self) -> Option<&dyn Error> {
Error::cause(&**self) Error::cause(&**self)
} }
} }
@ -368,7 +368,7 @@ impl Error for char::ParseCharError {
} }
// copied from any.rs // copied from any.rs
impl Error + 'static { impl dyn Error + 'static {
/// Returns true if the boxed type is the same as `T` /// Returns true if the boxed type is the same as `T`
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
#[inline] #[inline]
@ -390,7 +390,7 @@ impl Error + 'static {
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> { pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> {
if self.is::<T>() { if self.is::<T>() {
unsafe { unsafe {
Some(&*(self as *const Error as *const T)) Some(&*(self as *const dyn Error as *const T))
} }
} else { } else {
None None
@ -404,7 +404,7 @@ impl Error + 'static {
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> { pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> {
if self.is::<T>() { if self.is::<T>() {
unsafe { unsafe {
Some(&mut *(self as *mut Error as *mut T)) Some(&mut *(self as *mut dyn Error as *mut T))
} }
} else { } else {
None None
@ -412,60 +412,60 @@ impl Error + 'static {
} }
} }
impl Error + 'static + Send { impl dyn Error + 'static + Send {
/// Forwards to the method defined on the type `Any`. /// Forwards to the method defined on the type `Any`.
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
#[inline] #[inline]
pub fn is<T: Error + 'static>(&self) -> bool { 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`. /// Forwards to the method defined on the type `Any`.
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
#[inline] #[inline]
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> { 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`. /// Forwards to the method defined on the type `Any`.
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
#[inline] #[inline]
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> { 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`. /// Forwards to the method defined on the type `Any`.
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
#[inline] #[inline]
pub fn is<T: Error + 'static>(&self) -> bool { 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`. /// Forwards to the method defined on the type `Any`.
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
#[inline] #[inline]
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T> { 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`. /// Forwards to the method defined on the type `Any`.
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
#[inline] #[inline]
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T> { 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] #[inline]
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
/// Attempt to downcast the box to a concrete type. /// 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>() { if self.is::<T>() {
unsafe { 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)) Ok(Box::from_raw(raw as *mut T))
} }
} else { } else {
@ -474,30 +474,30 @@ impl Error {
} }
} }
impl Error + Send { impl dyn Error + Send {
#[inline] #[inline]
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
/// Attempt to downcast the box to a concrete type. /// Attempt to downcast the box to a concrete type.
pub fn downcast<T: Error + 'static>(self: Box<Self>) pub fn downcast<T: Error + 'static>(self: Box<Self>)
-> Result<Box<T>, Box<Error + Send>> { -> Result<Box<T>, Box<dyn Error + Send>> {
let err: Box<Error> = self; let err: Box<dyn Error> = self;
<Error>::downcast(err).map_err(|s| unsafe { <dyn Error>::downcast(err).map_err(|s| unsafe {
// reapply the Send marker // 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] #[inline]
#[stable(feature = "error_downcast", since = "1.3.0")] #[stable(feature = "error_downcast", since = "1.3.0")]
/// Attempt to downcast the box to a concrete type. /// Attempt to downcast the box to a concrete type.
pub fn downcast<T: Error + 'static>(self: Box<Self>) pub fn downcast<T: Error + 'static>(self: Box<Self>)
-> Result<Box<T>, Box<Self>> { -> Result<Box<T>, Box<Self>> {
let err: Box<Error> = self; let err: Box<dyn Error> = self;
<Error>::downcast(err).map_err(|s| unsafe { <dyn Error>::downcast(err).map_err(|s| unsafe {
// reapply the Send+Sync marker // 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 @@ mod tests {
#[test] #[test]
fn downcasting() { fn downcasting() {
let mut a = A; 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::<A>(), Some(&A));
assert_eq!(a.downcast_ref::<B>(), None); assert_eq!(a.downcast_ref::<B>(), None);
assert_eq!(a.downcast_mut::<A>(), Some(&mut A)); assert_eq!(a.downcast_mut::<A>(), Some(&mut A));
assert_eq!(a.downcast_mut::<B>(), None); 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>() { match a.downcast::<B>() {
Ok(..) => panic!("expected error"), Ok(..) => panic!("expected error"),
Err(e) => assert_eq!(*e.downcast::<A>().unwrap(), A), Err(e) => assert_eq!(*e.downcast::<A>().unwrap(), A),

View file

@ -891,7 +891,7 @@ impl Error for IntoStringError {
"C string contained non-utf8 bytes" "C string contained non-utf8 bytes"
} }
fn cause(&self) -> Option<&Error> { fn cause(&self) -> Option<&dyn Error> {
Some(&self.error) Some(&self.error)
} }
} }

View file

@ -83,7 +83,7 @@ enum Repr {
#[derive(Debug)] #[derive(Debug)]
struct Custom { struct Custom {
kind: ErrorKind, kind: ErrorKind,
error: Box<error::Error+Send+Sync>, error: Box<dyn error::Error+Send+Sync>,
} }
/// A list specifying general categories of I/O error. /// A list specifying general categories of I/O error.
@ -250,12 +250,12 @@ impl Error {
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub fn new<E>(kind: ErrorKind, error: E) -> Error 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()) 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 { Error {
repr: Repr::Custom(Box::new(Custom { repr: Repr::Custom(Box::new(Custom {
kind, kind,
@ -373,7 +373,7 @@ impl Error {
/// } /// }
/// ``` /// ```
#[stable(feature = "io_error_inner", since = "1.3.0")] #[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 { match self.repr {
Repr::Os(..) => None, Repr::Os(..) => None,
Repr::Simple(..) => None, Repr::Simple(..) => None,
@ -444,7 +444,7 @@ impl Error {
/// } /// }
/// ``` /// ```
#[stable(feature = "io_error_inner", since = "1.3.0")] #[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 { match self.repr {
Repr::Os(..) => None, Repr::Os(..) => None,
Repr::Simple(..) => None, Repr::Simple(..) => None,
@ -478,7 +478,7 @@ impl Error {
/// } /// }
/// ``` /// ```
#[stable(feature = "io_error_inner", since = "1.3.0")] #[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 { match self.repr {
Repr::Os(..) => None, Repr::Os(..) => None,
Repr::Simple(..) => None, Repr::Simple(..) => None,
@ -551,7 +551,7 @@ impl error::Error for Error {
} }
} }
fn cause(&self) -> Option<&error::Error> { fn cause(&self) -> Option<&dyn error::Error> {
match self.repr { match self.repr {
Repr::Os(..) => None, Repr::Os(..) => None,
Repr::Simple(..) => None, Repr::Simple(..) => None,

View file

@ -1972,7 +1972,7 @@ impl<T: BufRead> BufRead for Take<T> {
} }
} }
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]; let mut buf = [0];
loop { loop {
return match reader.read(&mut buf) { return match reader.read(&mut buf) {
@ -2081,7 +2081,7 @@ impl std_error::Error for CharsError {
CharsError::Other(ref e) => std_error::Error::description(e), 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 { match *self {
CharsError::NotUtf8 => None, CharsError::NotUtf8 => None,
CharsError::Other(ref e) => e.cause(), CharsError::Other(ref e) => e.cause(),

View file

@ -21,7 +21,7 @@ use thread::LocalKey;
/// Stdout used by print! and println! macros /// Stdout used by print! and println! macros
thread_local! { thread_local! {
static LOCAL_STDOUT: RefCell<Option<Box<Write + Send>>> = { static LOCAL_STDOUT: RefCell<Option<Box<dyn Write + Send>>> = {
RefCell::new(None) RefCell::new(None)
} }
} }
@ -624,7 +624,7 @@ impl<'a> fmt::Debug for StderrLock<'a> {
with a more general mechanism", with a more general mechanism",
issue = "0")] issue = "0")]
#[doc(hidden)] #[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 panicking::LOCAL_STDERR;
use mem; use mem;
LOCAL_STDERR.with(move |slot| { 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", with a more general mechanism",
issue = "0")] issue = "0")]
#[doc(hidden)] #[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; use mem;
LOCAL_STDOUT.with(move |slot| { LOCAL_STDOUT.with(move |slot| {
mem::replace(&mut *slot.borrow_mut(), sink) 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. /// However, if the actual I/O causes an error, this function does panic.
fn print_to<T>( fn print_to<T>(
args: fmt::Arguments, 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, global_s: fn() -> T,
label: &str, label: &str,
) )

View file

@ -223,7 +223,7 @@ mod tests {
assert_eq!(copy(&mut r, &mut w).unwrap(), 4); assert_eq!(copy(&mut r, &mut w).unwrap(), 4);
let mut r = repeat(0).take(1 << 17); 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] #[test]

View file

@ -58,7 +58,7 @@ impl<'a> Parser<'a> {
} }
// Return result of first successful parser // 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> { -> Option<T> {
for pf in parsers { for pf in parsers {
if let Some(r) = self.read_atomically(|p: &mut Parser| pf(p)) { if let Some(r) = self.read_atomically(|p: &mut Parser| pf(p)) {

View file

@ -927,7 +927,7 @@ mod tests {
use time::{Instant, Duration}; use time::{Instant, Duration};
use thread; use thread;
fn each_ip(f: &mut FnMut(SocketAddr)) { fn each_ip(f: &mut dyn FnMut(SocketAddr)) {
f(next_test_ip4()); f(next_test_ip4());
f(next_test_ip6()); f(next_test_ip6());
} }

View file

@ -826,7 +826,7 @@ mod tests {
use time::{Instant, Duration}; use time::{Instant, Duration};
use thread; 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_ip4(), next_test_ip4());
f(next_test_ip6(), next_test_ip6()); f(next_test_ip6(), next_test_ip6());
} }

View 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")] #[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) panicking::update_count_then_panic(payload)
} }

View file

@ -36,7 +36,7 @@ use sys_common::util;
use thread; use thread;
thread_local! { thread_local! {
pub static LOCAL_STDERR: RefCell<Option<Box<Write + Send>>> = { pub static LOCAL_STDERR: RefCell<Option<Box<dyn Write + Send>>> = {
RefCell::new(None) RefCell::new(None)
} }
} }
@ -64,7 +64,7 @@ extern {
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
enum Hook { enum Hook {
Default, Default,
Custom(*mut (Fn(&PanicInfo) + 'static + Sync + Send)), Custom(*mut (dyn Fn(&PanicInfo) + 'static + Sync + Send)),
} }
static HOOK_LOCK: RWLock = RWLock::new(); static HOOK_LOCK: RWLock = RWLock::new();
@ -104,7 +104,7 @@ static mut HOOK: Hook = Hook::Default;
/// panic!("Normal panic"); /// panic!("Normal panic");
/// ``` /// ```
#[stable(feature = "panic_hooks", since = "1.10.0")] #[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() { if thread::panicking() {
panic!("cannot modify the panic hook from a panicking thread"); 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"); /// panic!("Normal panic");
/// ``` /// ```
#[stable(feature = "panic_hooks", since = "1.10.0")] #[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() { if thread::panicking() {
panic!("cannot modify the panic hook from a panicking thread"); 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 thread = thread_info::current_thread();
let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>"); 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 '{}', {}", let _ = writeln!(err, "thread '{}' panicked at '{}', {}",
name, msg, location); name, msg, location);
@ -248,7 +248,7 @@ pub fn update_panic_count(amt: isize) -> usize {
pub use realstd::rt::update_panic_count; pub use realstd::rt::update_panic_count;
/// Invoke a closure, capturing the cause of an unwinding panic if one occurs. /// 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)] #[allow(unions_with_drop_fields)]
union Data<F, R> { union Data<F, R> {
f: F, f: F,
@ -369,12 +369,12 @@ fn continue_panic_fmt(info: &PanicInfo) -> ! {
} }
unsafe impl<'a> BoxMeUp for PanicPayload<'a> { 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()); let contents = mem::replace(self.fill(), String::new());
Box::into_raw(Box::new(contents)) Box::into_raw(Box::new(contents))
} }
fn get(&mut self) -> &(Any + Send) { fn get(&mut self) -> &(dyn Any + Send) {
self.fill() self.fill()
} }
} }
@ -419,15 +419,15 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
} }
unsafe impl<A: Send + 'static> BoxMeUp for 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() { 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(()), None => Box::new(()),
}; };
Box::into_raw(data) Box::into_raw(data)
} }
fn get(&mut self) -> &(Any + Send) { fn get(&mut self) -> &(dyn Any + Send) {
match self.inner { match self.inner {
Some(ref a) => a, Some(ref a) => a,
None => &(), None => &(),
@ -441,7 +441,7 @@ pub fn begin_panic<M: Any + Send>(msg: M, file_line_col: &(&'static str, u32, u3
/// Executes the primary logic for a panic, including checking for recursive /// Executes the primary logic for a panic, including checking for recursive
/// panics, panic hooks, and finally dispatching to the panic runtime to either /// panics, panic hooks, and finally dispatching to the panic runtime to either
/// abort or unwind. /// abort or unwind.
fn rust_panic_with_hook(payload: &mut BoxMeUp, fn rust_panic_with_hook(payload: &mut dyn BoxMeUp,
message: Option<&fmt::Arguments>, message: Option<&fmt::Arguments>,
file_line_col: &(&str, u32, u32)) -> ! { file_line_col: &(&str, u32, u32)) -> ! {
let (file, line, col) = *file_line_col; 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. /// 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); update_panic_count(1);
struct RewrapBox(Box<Any + Send>); struct RewrapBox(Box<dyn Any + Send>);
unsafe impl BoxMeUp for RewrapBox { 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(()))) 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 &*self.0
} }
} }
@ -517,9 +517,9 @@ pub fn update_count_then_panic(msg: Box<Any + Send>) -> ! {
/// A private no-mangle function on which to slap yer breakpoints. /// A private no-mangle function on which to slap yer breakpoints.
#[no_mangle] #[no_mangle]
#[allow(private_no_mangle_fns)] // yes we get it, but we like breakpoints #[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 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) __rust_start_panic(obj as usize)
}; };
rtabort!("failed to initiate panic, error {}", code) rtabort!("failed to initiate panic, error {}", code)

View file

@ -813,13 +813,13 @@ impl fmt::Debug for Output {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let stdout_utf8 = str::from_utf8(&self.stdout); 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, Ok(ref str) => str,
Err(_) => &self.stdout Err(_) => &self.stdout
}; };
let stderr_utf8 = str::from_utf8(&self.stderr); 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, Ok(ref str) => str,
Err(_) => &self.stderr Err(_) => &self.stderr
}; };

View file

@ -29,7 +29,7 @@ pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count};
// To reduce the generated code of the new `lang_start`, this function is doing // To reduce the generated code of the new `lang_start`, this function is doing
// the real work. // the real work.
#[cfg(not(test))] #[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 { argc: isize, argv: *const *const u8) -> isize {
use panic; use panic;
use sys; use sys;

View file

@ -1638,7 +1638,7 @@ impl<T: Send> error::Error for SendError<T> {
"sending on a closed channel" "sending on a closed channel"
} }
fn cause(&self) -> Option<&error::Error> { fn cause(&self) -> Option<&dyn error::Error> {
None None
} }
} }
@ -1681,7 +1681,7 @@ impl<T: Send> error::Error for TrySendError<T> {
} }
} }
fn cause(&self) -> Option<&error::Error> { fn cause(&self) -> Option<&dyn error::Error> {
None None
} }
} }
@ -1709,7 +1709,7 @@ impl error::Error for RecvError {
"receiving on a closed channel" "receiving on a closed channel"
} }
fn cause(&self) -> Option<&error::Error> { fn cause(&self) -> Option<&dyn error::Error> {
None None
} }
} }
@ -1742,7 +1742,7 @@ impl error::Error for TryRecvError {
} }
} }
fn cause(&self) -> Option<&error::Error> { fn cause(&self) -> Option<&dyn error::Error> {
None None
} }
} }
@ -1783,7 +1783,7 @@ impl error::Error for RecvTimeoutError {
} }
} }
fn cause(&self) -> Option<&error::Error> { fn cause(&self) -> Option<&dyn error::Error> {
None None
} }
} }

View file

@ -93,7 +93,7 @@ pub struct Handle<'rx, T:Send+'rx> {
next: *mut Handle<'static, ()>, next: *mut Handle<'static, ()>,
prev: *mut Handle<'static, ()>, prev: *mut Handle<'static, ()>,
added: bool, 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 // due to our fun transmutes, we be sure to place this at the end. (nothing
// previous relies on T) // previous relies on T)

View file

@ -309,7 +309,7 @@ impl Once {
#[cold] #[cold]
fn call_inner(&self, fn call_inner(&self,
ignore_poisoning: bool, ignore_poisoning: bool,
init: &mut FnMut(bool)) { init: &mut dyn FnMut(bool)) {
let mut state = self.state.load(Ordering::SeqCst); let mut state = self.state.load(Ordering::SeqCst);
'outer: loop { 'outer: loop {

View file

@ -32,7 +32,7 @@ unsafe impl Send for Thread {}
unsafe impl Sync for Thread {} unsafe impl Sync for Thread {}
impl 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 p = box p;
let mut native: libc::pthread_t = mem::zeroed(); let mut native: libc::pthread_t = mem::zeroed();
let mut attr: libc::pthread_attr_t = mem::zeroed(); let mut attr: libc::pthread_attr_t = mem::zeroed();

View file

@ -51,7 +51,7 @@ pub struct Command {
uid: Option<u32>, uid: Option<u32>,
gid: Option<u32>, gid: Option<u32>,
saw_nul: bool, saw_nul: bool,
closures: Vec<Box<FnMut() -> io::Result<()> + Send + Sync>>, closures: Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>>,
stdin: Option<Stdio>, stdin: Option<Stdio>,
stdout: Option<Stdio>, stdout: Option<Stdio>,
stderr: Option<Stdio>, stderr: Option<Stdio>,
@ -122,7 +122,7 @@ impl Command {
} }
pub fn before_exec(&mut self, 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); self.closures.push(f);
} }

View file

@ -28,7 +28,7 @@ unsafe impl Send for Thread {}
unsafe impl Sync for Thread {} unsafe impl Sync for Thread {}
impl 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 p = box p;
let id = cvt(syscall::clone(syscall::CLONE_VM | syscall::CLONE_FS | syscall::CLONE_FILES))?; let id = cvt(syscall::clone(syscall::CLONE_VM | syscall::CLONE_FS | syscall::CLONE_FILES))?;

View file

@ -52,7 +52,7 @@ pub struct Command {
uid: Option<uid_t>, uid: Option<uid_t>,
gid: Option<gid_t>, gid: Option<gid_t>,
saw_nul: bool, saw_nul: bool,
closures: Vec<Box<FnMut() -> io::Result<()> + Send + Sync>>, closures: Vec<Box<dyn FnMut() -> io::Result<()> + Send + Sync>>,
stdin: Option<Stdio>, stdin: Option<Stdio>,
stdout: Option<Stdio>, stdout: Option<Stdio>,
stderr: Option<Stdio>, stderr: Option<Stdio>,
@ -155,12 +155,12 @@ impl Command {
self.gid 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 &mut self.closures
} }
pub fn before_exec(&mut self, 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); self.closures.push(f);
} }

View file

@ -49,7 +49,7 @@ unsafe fn pthread_attr_setstacksize(_attr: *mut libc::pthread_attr_t,
} }
impl 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> { -> io::Result<Thread> {
let p = box p; let p = box p;
let mut native: libc::pthread_t = mem::zeroed(); let mut native: libc::pthread_t = mem::zeroed();

View file

@ -19,7 +19,7 @@ pub struct Thread(Void);
pub const DEFAULT_MIN_STACK_SIZE: usize = 4096; pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
impl 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> -> io::Result<Thread>
{ {
unsupported() unsupported()

View file

@ -28,7 +28,7 @@ pub struct Thread {
} }
impl 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> { -> io::Result<Thread> {
let p = box p; let p = box p;

View file

@ -17,7 +17,7 @@ use ptr;
use mem; use mem;
use sys_common::mutex::Mutex; 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 // 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 // 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 { unsafe {
let _guard = LOCK.lock(); let _guard = LOCK.lock();
if init() { if init() {

View file

@ -49,7 +49,7 @@ pub struct Frame {
const MAX_NB_FRAMES: usize = 100; const MAX_NB_FRAMES: usize = 100;
/// Prints the current backtrace. /// 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(); static LOCK: Mutex = Mutex::new();
// Use a lock to prevent mixed output in multithreading context. // 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 { let mut frames = [Frame {
exact_position: ptr::null(), exact_position: ptr::null(),
symbol_addr: 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. /// These output functions should now be used everywhere to ensure consistency.
/// You may want to also use `output_fileline`. /// 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<()> { s: Option<&str>, format: PrintFormat) -> io::Result<()> {
// Remove the `17: 0x0 - <unknown>` line. // Remove the `17: 0x0 - <unknown>` line.
if format == PrintFormat::Short && frame.exact_position == ptr::null() { 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`. /// See also `output`.
#[allow(dead_code)] #[allow(dead_code)]
fn output_fileline(w: &mut Write, fn output_fileline(w: &mut dyn Write,
file: &[u8], file: &[u8],
line: u32, line: u32,
format: PrintFormat) -> io::Result<()> { 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 // 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, // of other information in our symbols like hashes, version, type information,
// etc. Additionally, this doesn't handle glue symbols at all. // 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 // 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 // those endings first as they're one of the last manglings applied to
// symbol names. // symbol names.

View file

@ -251,7 +251,7 @@ impl<T> Error for TryLockError<T> {
} }
} }
fn cause(&self) -> Option<&Error> { fn cause(&self) -> Option<&dyn Error> {
match *self { match *self {
TryLockError::Poisoned(ref p) => Some(p), TryLockError::Poisoned(ref p) => Some(p),
_ => None _ => None

View file

@ -21,7 +21,7 @@ pub unsafe fn start_thread(main: *mut u8) {
let _handler = stack_overflow::Handler::new(); let _handler = stack_overflow::Handler::new();
// Finally, let's run some code. // 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 { pub fn min_stack() -> usize {

View file

@ -1175,7 +1175,7 @@ impl fmt::Debug for Thread {
/// ///
/// [`Result`]: ../../std/result/enum.Result.html /// [`Result`]: ../../std/result/enum.Result.html
#[stable(feature = "rust1", since = "1.0.0")] #[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 // 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 // and the parent thread. Memory is shared through the `Arc` within and there's
@ -1438,7 +1438,7 @@ mod tests {
rx.recv().unwrap(); 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 (tx, rx) = channel();
let x: Box<_> = box 1; let x: Box<_> = box 1;
@ -1485,7 +1485,7 @@ mod tests {
// (well, it would if the constant were 8000+ - I lowered it to be more // (well, it would if the constant were 8000+ - I lowered it to be more
// valgrind-friendly. try this at home, instead..!) // valgrind-friendly. try this at home, instead..!)
const GENERATIONS: u32 = 16; 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|| { return Box::new(move|| {
if x < GENERATIONS { if x < GENERATIONS {
thread::spawn(move|| child_no(x+1)()); thread::spawn(move|| child_no(x+1)());
@ -1531,10 +1531,10 @@ mod tests {
#[test] #[test]
fn test_try_panic_message_any() { fn test_try_panic_message_any() {
match thread::spawn(move|| { match thread::spawn(move|| {
panic!(box 413u16 as Box<Any + Send>); panic!(box 413u16 as Box<dyn Any + Send>);
}).join() { }).join() {
Err(e) => { Err(e) => {
type T = Box<Any + Send>; type T = Box<dyn Any + Send>;
assert!(e.is::<T>()); assert!(e.is::<T>());
let any = e.downcast::<T>().unwrap(); let any = e.downcast::<T>().unwrap();
assert!(any.is::<u16>()); assert!(any.is::<u16>());

View file

@ -14,8 +14,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/", html_root_url = "https://doc.rust-lang.org/nightly/",

View file

@ -10,8 +10,6 @@
//! Syntax extensions in the Rust compiler. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

View file

@ -14,8 +14,6 @@
//! //!
//! This API is completely unstable and subject to change. //! 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", #![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_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]

Some files were not shown because too many files have changed in this diff Show more