Skip to content

Commit 85a6b92

Browse files
committed
Rollup merge of rust-lang#48477 - Manishearth:dyn-trait-fixes, r=nmatsakis
Fixes rust-lang#47311. r? @nrc
2 parents e8af0f4 + 40f218f commit 85a6b92

File tree

35 files changed

+94
-94
lines changed

35 files changed

+94
-94
lines changed

src/librustc/dep_graph/debug.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub struct EdgeFilter {
5454
}
5555

5656
impl EdgeFilter {
57-
pub fn new(test: &str) -> Result<EdgeFilter, Box<Error>> {
57+
pub fn new(test: &str) -> Result<EdgeFilter, Box<dyn Error>> {
5858
let parts: Vec<_> = test.split("->").collect();
5959
if parts.len() != 2 {
6060
Err(format!("expected a filter like `a&b -> c&d`, not `{}`", test).into())

src/librustc/hir/lowering.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ pub struct LoweringContext<'a> {
8080
// Use to assign ids to hir nodes that do not directly correspond to an ast node
8181
sess: &'a Session,
8282

83-
cstore: &'a CrateStore,
83+
cstore: &'a dyn CrateStore,
8484

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

9292
/// The items being lowered are collected here.
@@ -177,10 +177,10 @@ enum ImplTraitContext {
177177
}
178178

179179
pub fn lower_crate(sess: &Session,
180-
cstore: &CrateStore,
180+
cstore: &dyn CrateStore,
181181
dep_graph: &DepGraph,
182182
krate: &Crate,
183-
resolver: &mut Resolver)
183+
resolver: &mut dyn Resolver)
184184
-> hir::Crate {
185185
// We're constructing the HIR here; we don't care what we will
186186
// read, since we haven't even constructed the *input* to

src/librustc/hir/map/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
123123

124124
pub(super) fn finalize_and_compute_crate_hash(self,
125125
crate_disambiguator: CrateDisambiguator,
126-
cstore: &CrateStore,
126+
cstore: &dyn CrateStore,
127127
codemap: &CodeMap,
128128
commandline_args_hash: u64)
129129
-> (Vec<MapEntry<'hir>>, Svh) {

src/librustc/hir/map/def_collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct DefCollector<'a> {
2626
definitions: &'a mut Definitions,
2727
parent_def: Option<DefIndex>,
2828
expansion: Mark,
29-
pub visit_macro_invoc: Option<&'a mut FnMut(MacroInvocationData)>,
29+
pub visit_macro_invoc: Option<&'a mut dyn FnMut(MacroInvocationData)>,
3030
}
3131

3232
pub struct MacroInvocationData {

src/librustc/hir/map/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use dep_graph::{DepGraph, DepNode, DepKind, DepNodeIndex};
1919

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

22+
use middle::cstore::CrateStore;
23+
2224
use syntax::abi::Abi;
2325
use syntax::ast::{self, Name, NodeId, CRATE_NODE_ID};
2426
use syntax::codemap::Spanned;
@@ -1136,8 +1138,9 @@ impl Named for StructField { fn name(&self) -> Name { self.name } }
11361138
impl Named for TraitItem { fn name(&self) -> Name { self.name } }
11371139
impl Named for ImplItem { fn name(&self) -> Name { self.name } }
11381140

1141+
11391142
pub fn map_crate<'hir>(sess: &::session::Session,
1140-
cstore: &::middle::cstore::CrateStore,
1143+
cstore: &dyn CrateStore,
11411144
forest: &'hir mut Forest,
11421145
definitions: &'hir Definitions)
11431146
-> Map<'hir> {

src/librustc/hir/print.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub trait PpAnn {
6262

6363
pub struct NoAnn;
6464
impl PpAnn for NoAnn {}
65-
pub const NO_ANN: &'static PpAnn = &NoAnn;
65+
pub const NO_ANN: &'static dyn PpAnn = &NoAnn;
6666

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

8989
impl<'a> PrintState<'a> for State<'a> {
@@ -126,9 +126,9 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
126126
sess: &ParseSess,
127127
krate: &hir::Crate,
128128
filename: FileName,
129-
input: &mut Read,
130-
out: Box<Write + 'a>,
131-
ann: &'a PpAnn,
129+
input: &mut dyn Read,
130+
out: Box<dyn Write + 'a>,
131+
ann: &'a dyn PpAnn,
132132
is_expanded: bool)
133133
-> io::Result<()> {
134134
let mut s = State::new_from_input(cm, sess, filename, input, out, ann, is_expanded);
@@ -145,9 +145,9 @@ impl<'a> State<'a> {
145145
pub fn new_from_input(cm: &'a CodeMap,
146146
sess: &ParseSess,
147147
filename: FileName,
148-
input: &mut Read,
149-
out: Box<Write + 'a>,
150-
ann: &'a PpAnn,
148+
input: &mut dyn Read,
149+
out: Box<dyn Write + 'a>,
150+
ann: &'a dyn PpAnn,
151151
is_expanded: bool)
152152
-> State<'a> {
153153
let (cmnts, lits) = comments::gather_comments_and_literals(sess, filename, input);
@@ -167,8 +167,8 @@ impl<'a> State<'a> {
167167
}
168168

169169
pub fn new(cm: &'a CodeMap,
170-
out: Box<Write + 'a>,
171-
ann: &'a PpAnn,
170+
out: Box<dyn Write + 'a>,
171+
ann: &'a dyn PpAnn,
172172
comments: Option<Vec<comments::Comment>>,
173173
literals: Option<Vec<comments::Literal>>)
174174
-> State<'a> {
@@ -184,7 +184,7 @@ impl<'a> State<'a> {
184184
}
185185
}
186186

187-
pub fn to_string<F>(ann: &PpAnn, f: F) -> String
187+
pub fn to_string<F>(ann: &dyn PpAnn, f: F) -> String
188188
where F: FnOnce(&mut State) -> io::Result<()>
189189
{
190190
let mut wr = Vec::new();

src/librustc/ich/hcx.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
4949
pub struct StableHashingContext<'gcx> {
5050
sess: &'gcx Session,
5151
definitions: &'gcx Definitions,
52-
cstore: &'gcx CrateStore,
52+
cstore: &'gcx dyn CrateStore,
5353
body_resolver: BodyResolver<'gcx>,
5454
hash_spans: bool,
5555
hash_bodies: bool,
@@ -88,7 +88,7 @@ impl<'gcx> StableHashingContext<'gcx> {
8888
pub fn new(sess: &'gcx Session,
8989
krate: &'gcx hir::Crate,
9090
definitions: &'gcx Definitions,
91-
cstore: &'gcx CrateStore)
91+
cstore: &'gcx dyn CrateStore)
9292
-> Self {
9393
let hash_spans_initial = !sess.opts.debugging_opts.incremental_ignore_spans;
9494

src/librustc/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ impl<'a, 'gcx, 'tcx> GenericKind<'tcx> {
896896
}
897897

898898
impl<'a, 'gcx, 'tcx> VerifyBound<'tcx> {
899-
fn for_each_region(&self, f: &mut FnMut(ty::Region<'tcx>)) {
899+
fn for_each_region(&self, f: &mut dyn FnMut(ty::Region<'tcx>)) {
900900
match self {
901901
&VerifyBound::AnyRegion(ref rs) | &VerifyBound::AllRegions(ref rs) => for &r in rs {
902902
f(r);

src/librustc/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
html_root_url = "https://doc.rust-lang.org/nightly/")]
4242
#![deny(warnings)]
4343

44-
#![cfg_attr(not(stage0), allow(bare_trait_object))]
45-
4644
#![feature(box_patterns)]
4745
#![feature(box_syntax)]
4846
#![feature(conservative_impl_trait)]

src/librustc/lint/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ pub trait EarlyLintPass: LintPass {
280280
}
281281

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

286286
/// Identifies a lint known to the compiler.
287287
#[derive(Clone, Copy, Debug)]

src/librustc/middle/cstore.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ pub struct ExternBodyNestedBodies {
225225
/// (it'd break incremental compilation) and should only be called pre-HIR (e.g.
226226
/// during resolve)
227227
pub trait CrateStore {
228-
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<Any>;
228+
fn crate_data_as_rc_any(&self, krate: CrateNum) -> Lrc<dyn Any>;
229229

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

233233
// resolve
234234
fn def_key(&self, def: DefId) -> DefKey;
@@ -297,7 +297,7 @@ pub struct DummyCrateStore;
297297

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

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

357357
pub trait CrateLoader {

src/librustc/middle/dependency_format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ fn attempt_static<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<DependencyLis
319319
// also skip this step entirely.
320320
fn activate_injected_dep(injected: Option<CrateNum>,
321321
list: &mut DependencyList,
322-
replaces_injected: &Fn(CrateNum) -> bool) {
322+
replaces_injected: &dyn Fn(CrateNum) -> bool) {
323323
for (i, slot) in list.iter().enumerate() {
324324
let cnum = CrateNum::new(i + 1);
325325
if !replaces_injected(cnum) {

src/librustc/middle/expr_use_visitor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl OverloadedCallType {
239239
// This is the code that actually walks the tree.
240240
pub struct ExprUseVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
241241
mc: mc::MemCategorizationContext<'a, 'gcx, 'tcx>,
242-
delegate: &'a mut Delegate<'tcx>,
242+
delegate: &'a mut dyn Delegate<'tcx>,
243243
param_env: ty::ParamEnv<'tcx>,
244244
}
245245

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

296296
impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
297-
pub fn with_infer(delegate: &'a mut (Delegate<'tcx>+'a),
297+
pub fn with_infer(delegate: &'a mut (dyn Delegate<'tcx>+'a),
298298
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
299299
param_env: ty::ParamEnv<'tcx>,
300300
region_scope_tree: &'a region::ScopeTree,

src/librustc/middle/liveness.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
673673
}
674674

675675
fn write_vars<F>(&self,
676-
wr: &mut Write,
676+
wr: &mut dyn Write,
677677
ln: LiveNode,
678678
mut test: F)
679679
-> io::Result<()> where
@@ -694,7 +694,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
694694
fn ln_str(&self, ln: LiveNode) -> String {
695695
let mut wr = Vec::new();
696696
{
697-
let wr = &mut wr as &mut Write;
697+
let wr = &mut wr as &mut dyn Write;
698698
write!(wr, "[ln({:?}) of kind {:?} reads", ln.get(), self.ir.lnk(ln));
699699
self.write_vars(wr, ln, |idx| self.users[idx].reader);
700700
write!(wr, " writes");

src/librustc/mir/interpret/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'tcx> From<EvalErrorKind<'tcx>> for EvalError<'tcx> {
3535
pub enum EvalErrorKind<'tcx> {
3636
/// This variant is used by machines to signal their own errors that do not
3737
/// match an existing variant
38-
MachineError(Box<Error>),
38+
MachineError(Box<dyn Error>),
3939
FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>),
4040
NoMirFor(String),
4141
UnterminatedCString(MemoryPointer),
@@ -248,7 +248,7 @@ impl<'tcx> Error for EvalError<'tcx> {
248248
}
249249
}
250250

251-
fn cause(&self) -> Option<&Error> {
251+
fn cause(&self) -> Option<&dyn Error> {
252252
use self::EvalErrorKind::*;
253253
match self.kind {
254254
MachineError(ref inner) => Some(&**inner),

src/librustc/session/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ macro_rules! hash_option {
341341
($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [UNTRACKED]) => ({});
342342
($opt_name:ident, $opt_expr:expr, $sub_hashes:expr, [TRACKED]) => ({
343343
if $sub_hashes.insert(stringify!($opt_name),
344-
$opt_expr as &dep_tracking::DepTrackingHash).is_some() {
344+
$opt_expr as &dyn dep_tracking::DepTrackingHash).is_some() {
345345
bug!("Duplicate key in CLI DepTrackingHash: {}", stringify!($opt_name))
346346
}
347347
});
@@ -1456,7 +1456,7 @@ pub enum OptionStability {
14561456
}
14571457

14581458
pub struct RustcOptGroup {
1459-
pub apply: Box<Fn(&mut getopts::Options) -> &mut getopts::Options>,
1459+
pub apply: Box<dyn Fn(&mut getopts::Options) -> &mut getopts::Options>,
14601460
pub name: &'static str,
14611461
pub stability: OptionStability,
14621462
}
@@ -2256,7 +2256,7 @@ mod dep_tracking {
22562256
}
22572257

22582258
// This is a stable hash because BTreeMap is a sorted container
2259-
pub fn stable_hash(sub_hashes: BTreeMap<&'static str, &DepTrackingHash>,
2259+
pub fn stable_hash(sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>,
22602260
hasher: &mut DefaultHasher,
22612261
error_format: ErrorOutputType) {
22622262
for (key, sub_hash) in sub_hashes {

src/librustc/session/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ pub fn build_session_with_codemap(sopts: config::Options,
905905
local_crate_source_file: Option<PathBuf>,
906906
registry: errors::registry::Registry,
907907
codemap: Lrc<codemap::CodeMap>,
908-
emitter_dest: Option<Box<Write + Send>>)
908+
emitter_dest: Option<Box<dyn Write + Send>>)
909909
-> Session {
910910
// FIXME: This is not general enough to make the warning lint completely override
911911
// normal diagnostic warnings, since the warning lint can also be denied and changed
@@ -924,7 +924,7 @@ pub fn build_session_with_codemap(sopts: config::Options,
924924

925925
let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace;
926926

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

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

11401140
pub fn early_warn(output: config::ErrorOutputType, msg: &str) {
1141-
let emitter: Box<Emitter> = match output {
1141+
let emitter: Box<dyn Emitter> = match output {
11421142
config::ErrorOutputType::HumanReadable(color_config) => {
11431143
Box::new(EmitterWriter::stderr(color_config, None, false, false))
11441144
}

src/librustc/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
499499
item_name: ast::Name,
500500
_impl_item_def_id: DefId,
501501
trait_item_def_id: DefId,
502-
requirement: &fmt::Display)
502+
requirement: &dyn fmt::Display)
503503
-> DiagnosticBuilder<'tcx>
504504
{
505505
let msg = "impl has stricter requirements than trait";

src/librustc/traits/specialize/specialization_graph.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ impl<'a, 'gcx, 'tcx> Children {
190190
Ok(Inserted::BecameNewSibling(last_lint))
191191
}
192192

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

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

0 commit comments

Comments
 (0)