Skip to content

Commit

Permalink
Rollup merge of rust-lang#48477 - Manishearth:dyn-trait-fixes, r=nmat…
Browse files Browse the repository at this point in the history
…sakis

Fixes rust-lang#47311.
r? @nrc
  • Loading branch information
Manishearth committed Mar 3, 2018
2 parents e8af0f4 + 40f218f commit 85a6b92
Show file tree
Hide file tree
Showing 35 changed files with 94 additions and 94 deletions.
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct EdgeFilter {
}

impl EdgeFilter {
pub fn new(test: &str) -> Result<EdgeFilter, Box<Error>> {
pub fn new(test: &str) -> Result<EdgeFilter, Box<dyn Error>> {
let parts: Vec<_> = test.split("->").collect();
if parts.len() != 2 {
Err(format!("expected a filter like `a&b -> c&d`, not `{}`", test).into())
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ pub struct LoweringContext<'a> {
// Use to assign ids to hir nodes that do not directly correspond to an ast node
sess: &'a Session,

cstore: &'a CrateStore,
cstore: &'a dyn CrateStore,

// As we walk the AST we must keep track of the current 'parent' def id (in
// the form of a DefIndex) so that if we create a new node which introduces
// a definition, then we can properly create the def id.
parent_def: Option<DefIndex>,
resolver: &'a mut Resolver,
resolver: &'a mut dyn Resolver,
name_map: FxHashMap<Ident, Name>,

/// The items being lowered are collected here.
Expand Down Expand Up @@ -177,10 +177,10 @@ enum ImplTraitContext {
}

pub fn lower_crate(sess: &Session,
cstore: &CrateStore,
cstore: &dyn CrateStore,
dep_graph: &DepGraph,
krate: &Crate,
resolver: &mut Resolver)
resolver: &mut dyn Resolver)
-> hir::Crate {
// We're constructing the HIR here; we don't care what we will
// read, since we haven't even constructed the *input* to
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {

pub(super) fn finalize_and_compute_crate_hash(self,
crate_disambiguator: CrateDisambiguator,
cstore: &CrateStore,
cstore: &dyn CrateStore,
codemap: &CodeMap,
commandline_args_hash: u64)
-> (Vec<MapEntry<'hir>>, Svh) {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct DefCollector<'a> {
definitions: &'a mut Definitions,
parent_def: Option<DefIndex>,
expansion: Mark,
pub visit_macro_invoc: Option<&'a mut FnMut(MacroInvocationData)>,
pub visit_macro_invoc: Option<&'a mut dyn FnMut(MacroInvocationData)>,
}

pub struct MacroInvocationData {
Expand Down
5 changes: 4 additions & 1 deletion src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use dep_graph::{DepGraph, DepNode, DepKind, DepNodeIndex};

use hir::def_id::{CRATE_DEF_INDEX, DefId, LocalDefId, DefIndexAddressSpace};

use middle::cstore::CrateStore;

use syntax::abi::Abi;
use syntax::ast::{self, Name, NodeId, CRATE_NODE_ID};
use syntax::codemap::Spanned;
Expand Down Expand Up @@ -1136,8 +1138,9 @@ impl Named for StructField { fn name(&self) -> Name { self.name } }
impl Named for TraitItem { fn name(&self) -> Name { self.name } }
impl Named for ImplItem { fn name(&self) -> Name { self.name } }


pub fn map_crate<'hir>(sess: &::session::Session,
cstore: &::middle::cstore::CrateStore,
cstore: &dyn CrateStore,
forest: &'hir mut Forest,
definitions: &'hir Definitions)
-> Map<'hir> {
Expand Down
22 changes: 11 additions & 11 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub trait PpAnn {

pub struct NoAnn;
impl PpAnn for NoAnn {}
pub const NO_ANN: &'static PpAnn = &NoAnn;
pub const NO_ANN: &'static dyn PpAnn = &NoAnn;

impl PpAnn for hir::Crate {
fn nested(&self, state: &mut State, nested: Nested) -> io::Result<()> {
Expand All @@ -83,7 +83,7 @@ pub struct State<'a> {
literals: Peekable<vec::IntoIter<comments::Literal>>,
cur_cmnt: usize,
boxes: Vec<pp::Breaks>,
ann: &'a (PpAnn + 'a),
ann: &'a (dyn PpAnn + 'a),
}

impl<'a> PrintState<'a> for State<'a> {
Expand Down Expand Up @@ -126,9 +126,9 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
sess: &ParseSess,
krate: &hir::Crate,
filename: FileName,
input: &mut Read,
out: Box<Write + 'a>,
ann: &'a PpAnn,
input: &mut dyn Read,
out: Box<dyn Write + 'a>,
ann: &'a dyn PpAnn,
is_expanded: bool)
-> io::Result<()> {
let mut s = State::new_from_input(cm, sess, filename, input, out, ann, is_expanded);
Expand All @@ -145,9 +145,9 @@ impl<'a> State<'a> {
pub fn new_from_input(cm: &'a CodeMap,
sess: &ParseSess,
filename: FileName,
input: &mut Read,
out: Box<Write + 'a>,
ann: &'a PpAnn,
input: &mut dyn Read,
out: Box<dyn Write + 'a>,
ann: &'a dyn PpAnn,
is_expanded: bool)
-> State<'a> {
let (cmnts, lits) = comments::gather_comments_and_literals(sess, filename, input);
Expand All @@ -167,8 +167,8 @@ impl<'a> State<'a> {
}

pub fn new(cm: &'a CodeMap,
out: Box<Write + 'a>,
ann: &'a PpAnn,
out: Box<dyn Write + 'a>,
ann: &'a dyn PpAnn,
comments: Option<Vec<comments::Comment>>,
literals: Option<Vec<comments::Literal>>)
-> State<'a> {
Expand All @@ -184,7 +184,7 @@ impl<'a> State<'a> {
}
}

pub fn to_string<F>(ann: &PpAnn, f: F) -> String
pub fn to_string<F>(ann: &dyn PpAnn, f: F) -> String
where F: FnOnce(&mut State) -> io::Result<()>
{
let mut wr = Vec::new();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ich/hcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
pub struct StableHashingContext<'gcx> {
sess: &'gcx Session,
definitions: &'gcx Definitions,
cstore: &'gcx CrateStore,
cstore: &'gcx dyn CrateStore,
body_resolver: BodyResolver<'gcx>,
hash_spans: bool,
hash_bodies: bool,
Expand Down Expand Up @@ -88,7 +88,7 @@ impl<'gcx> StableHashingContext<'gcx> {
pub fn new(sess: &'gcx Session,
krate: &'gcx hir::Crate,
definitions: &'gcx Definitions,
cstore: &'gcx CrateStore)
cstore: &'gcx dyn CrateStore)
-> Self {
let hash_spans_initial = !sess.opts.debugging_opts.incremental_ignore_spans;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/region_constraints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
}

impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> {
fn for_each_region(&self, f: &mut FnMut(ty::Region<'tcx>)) {
fn for_each_region(&self, f: &mut dyn FnMut(ty::Region<'tcx>)) {
match self {
&VerifyBound::AnyRegion(ref rs) | &VerifyBound::AllRegions(ref rs) => for &r in rs {
f(r);
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]

#![cfg_attr(not(stage0), allow(bare_trait_object))]

#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/lint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ pub trait EarlyLintPass: LintPass {
}

/// A lint pass boxed up as a trait object.
pub type EarlyLintPassObject = Box<EarlyLintPass + 'static>;
pub type LateLintPassObject = Box<for<'a, 'tcx> LateLintPass<'a, 'tcx> + 'static>;
pub type EarlyLintPassObject = Box<dyn EarlyLintPass + 'static>;
pub type LateLintPassObject = Box<dyn for<'a, 'tcx> LateLintPass<'a, 'tcx> + 'static>;

/// Identifies a lint known to the compiler.
#[derive(Clone, Copy, Debug)]
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ pub struct ExternBodyNestedBodies {
/// (it'd break incremental compilation) and should only be called pre-HIR (e.g.
/// during resolve)
pub trait CrateStore {
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<Any>;
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<dyn Any>;

// access to the metadata loader
fn metadata_loader(&self) -> &MetadataLoader;
fn metadata_loader(&self) -> &dyn MetadataLoader;

// resolve
fn def_key(&self, def: DefId) -> DefKey;
Expand Down Expand Up @@ -297,7 +297,7 @@ pub struct DummyCrateStore;

#[allow(unused_variables)]
impl CrateStore for DummyCrateStore {
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<Any>
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<dyn Any>
{ bug!("crate_data_as_rc_any") }
// item info
fn visibility_untracked(&self, def: DefId) -> ty::Visibility { bug!("visibility") }
Expand Down Expand Up @@ -351,7 +351,7 @@ impl CrateStore for DummyCrateStore {
fn postorder_cnums_untracked(&self) -> Vec<CrateNum> { bug!("postorder_cnums_untracked") }

// access to the metadata loader
fn metadata_loader(&self) -> &MetadataLoader { bug!("metadata_loader") }
fn metadata_loader(&self) -> &dyn MetadataLoader { bug!("metadata_loader") }
}

pub trait CrateLoader {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/dependency_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<DependencyLis
// also skip this step entirely.
fn activate_injected_dep(injected: Option<CrateNum>,
list: &mut DependencyList,
replaces_injected: &Fn(CrateNum) -> bool) {
replaces_injected: &dyn Fn(CrateNum) -> bool) {
for (i, slot) in list.iter().enumerate() {
let cnum = CrateNum::new(i + 1);
if !replaces_injected(cnum) {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl OverloadedCallType {
// This is the code that actually walks the tree.
pub struct ExprUseVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
mc: mc::MemCategorizationContext<'a, 'gcx, 'tcx>,
delegate: &'a mut Delegate<'tcx>,
delegate: &'a mut dyn Delegate<'tcx>,
param_env: ty::ParamEnv<'tcx>,
}

Expand Down Expand Up @@ -274,7 +274,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
/// `None` means that rvalues will be given more conservative lifetimes.
///
/// See also `with_infer`, which is used *during* typeck.
pub fn new(delegate: &'a mut (Delegate<'tcx>+'a),
pub fn new(delegate: &'a mut (dyn Delegate<'tcx>+'a),
tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
Expand All @@ -294,7 +294,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx, 'tcx> {
}

impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
pub fn with_infer(delegate: &'a mut (Delegate<'tcx>+'a),
pub fn with_infer(delegate: &'a mut (dyn Delegate<'tcx>+'a),
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
region_scope_tree: &'a region::ScopeTree,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}

fn write_vars<F>(&self,
wr: &mut Write,
wr: &mut dyn Write,
ln: LiveNode,
mut test: F)
-> io::Result<()> where
Expand All @@ -694,7 +694,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn ln_str(&self, ln: LiveNode) -> String {
let mut wr = Vec::new();
{
let wr = &mut wr as &mut Write;
let wr = &mut wr as &mut dyn Write;
write!(wr, "[ln({:?}) of kind {:?} reads", ln.get(), self.ir.lnk(ln));
self.write_vars(wr, ln, |idx| self.users[idx].reader);
write!(wr, " writes");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'tcx> From<EvalErrorKind<'tcx>> for EvalError<'tcx> {
pub enum EvalErrorKind<'tcx> {
/// This variant is used by machines to signal their own errors that do not
/// match an existing variant
MachineError(Box<Error>),
MachineError(Box<dyn Error>),
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
NoMirFor(String),
UnterminatedCString(MemoryPointer),
Expand Down Expand Up @@ -248,7 +248,7 @@ impl<'tcx> Error for EvalError<'tcx> {
}
}

fn cause(&self) -> Option<&Error> {
fn cause(&self) -> Option<&dyn Error> {
use self::EvalErrorKind::*;
match self.kind {
MachineError(ref inner) => Some(&**inner),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ macro_rules! hash_option {
($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [UNTRACKED]) => ({});
($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [TRACKED]) => ({
if $sub_hashes.insert(stringify!($opt_name),
$opt_expr as &dep_tracking::DepTrackingHash).is_some() {
$opt_expr as &dyn dep_tracking::DepTrackingHash).is_some() {
bug!("Duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
}
});
Expand Down Expand Up @@ -1456,7 +1456,7 @@ pub enum OptionStability {
}

pub struct RustcOptGroup {
pub apply: Box<Fn(&mut getopts::Options) -> &mut getopts::Options>,
pub apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
pub name: &'static str,
pub stability: OptionStability,
}
Expand Down Expand Up @@ -2256,7 +2256,7 @@ mod dep_tracking {
}

// This is a stable hash because BTreeMap is a sorted container
pub fn stable_hash(sub_hashes: BTreeMap<&'static str, &DepTrackingHash>,
pub fn stable_hash(sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>,
hasher: &mut DefaultHasher,
error_format: ErrorOutputType) {
for (key, sub_hash) in sub_hashes {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ pub fn build_session_with_codemap(sopts: config::Options,
local_crate_source_file: Option<PathBuf>,
registry: errors::registry::Registry,
codemap: Lrc<codemap::CodeMap>,
emitter_dest: Option<Box<Write + Send>>)
emitter_dest: Option<Box<dyn Write + Send>>)
-> Session {
// FIXME: This is not general enough to make the warning lint completely override
// normal diagnostic warnings, since the warning lint can also be denied and changed
Expand All @@ -924,7 +924,7 @@ pub fn build_session_with_codemap(sopts: config::Options,

let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace;

let emitter: Box<Emitter> = match (sopts.error_format, emitter_dest) {
let emitter: Box<dyn Emitter> = match (sopts.error_format, emitter_dest) {
(config::ErrorOutputType::HumanReadable(color_config), None) => {
Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()),
false, sopts.debugging_opts.teach)
Expand Down Expand Up @@ -1123,7 +1123,7 @@ pub enum IncrCompSession {
}

pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
let emitter: Box<Emitter> = match output {
let emitter: Box<dyn Emitter> = match output {
config::ErrorOutputType::HumanReadable(color_config) => {
Box::new(EmitterWriter::stderr(color_config, None, false, false))
}
Expand All @@ -1138,7 +1138,7 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
}

pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
let emitter: Box<Emitter> = match output {
let emitter: Box<dyn Emitter> = match output {
config::ErrorOutputType::HumanReadable(color_config) => {
Box::new(EmitterWriter::stderr(color_config, None, false, false))
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
item_name: ast::Name,
_impl_item_def_id: DefId,
trait_item_def_id: DefId,
requirement: &fmt::Display)
requirement: &dyn fmt::Display)
-> DiagnosticBuilder<'tcx>
{
let msg = "impl has stricter requirements than trait";
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/specialize/specialization_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,13 @@ impl<'a, 'gcx, 'tcx> Children {
Ok(Inserted::BecameNewSibling(last_lint))
}

fn iter_mut(&'a mut self) -> Box<Iterator<Item = &'a mut DefId> + 'a> {
fn iter_mut(&'a mut self) -> Box<dyn Iterator<Item = &'a mut DefId> + 'a> {
let nonblanket = self.nonblanket_impls.iter_mut().flat_map(|(_, v)| v.iter_mut());
Box::new(self.blanket_impls.iter_mut().chain(nonblanket))
}

fn filtered_mut(&'a mut self, sty: SimplifiedType)
-> Box<Iterator<Item = &'a mut DefId> + 'a> {
-> Box<dyn Iterator<Item = &'a mut DefId> + 'a> {
let nonblanket = self.nonblanket_impls.entry(sty).or_insert(vec![]).iter_mut();
Box::new(self.blanket_impls.iter_mut().chain(nonblanket))
}
Expand Down
Loading

0 comments on commit 85a6b92

Please sign in to comment.