Rollup merge of #37296 - srinivasreddy:librustc_driver, r=nikomatsakis

run rustfmt on librustc_driver folder
This commit is contained in:
Guillaume Gomez
2016-11-01 16:15:51 +01:00
committed by GitHub
3 changed files with 191 additions and 188 deletions

View File

@@ -233,14 +233,11 @@ impl PpSourceMode {
arenas, arenas,
id, id,
|tcx, _, _, _| { |tcx, _, _, _| {
let annotation = TypedAnnotation { let annotation = TypedAnnotation { tcx: tcx };
tcx: tcx,
};
let _ignore = tcx.dep_graph.in_ignore(); let _ignore = tcx.dep_graph.in_ignore();
f(&annotation, f(&annotation, payload, ast_map.forest.krate())
payload, }),
ast_map.forest.krate()) sess)
}), sess)
} }
_ => panic!("Should use call_with_pp_support"), _ => panic!("Should use call_with_pp_support"),
} }
@@ -281,9 +278,11 @@ trait HirPrinterSupport<'ast>: pprust_hir::PpAnn {
/// Computes an user-readable representation of a path, if possible. /// Computes an user-readable representation of a path, if possible.
fn node_path(&self, id: ast::NodeId) -> Option<String> { fn node_path(&self, id: ast::NodeId) -> Option<String> {
self.ast_map().and_then(|map| map.def_path_from_id(id)).map(|path| { self.ast_map().and_then(|map| map.def_path_from_id(id)).map(|path| {
path.data.into_iter().map(|elem| { path.data
elem.data.to_string() .into_iter()
}).collect::<Vec<_>>().join("::") .map(|elem| elem.data.to_string())
.collect::<Vec<_>>()
.join("::")
}) })
} }
} }
@@ -352,7 +351,8 @@ impl<'ast> pprust::PpAnn for IdentifiedAnnotation<'ast> {
} }
fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> { fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> {
match node { match node {
pprust::NodeIdent(_) | pprust::NodeName(_) => Ok(()), pprust::NodeIdent(_) |
pprust::NodeName(_) => Ok(()),
pprust::NodeItem(item) => { pprust::NodeItem(item) => {
pp::space(&mut s.s)?; pp::space(&mut s.s)?;
@@ -617,15 +617,14 @@ impl ReplaceBodyWithLoop {
impl fold::Folder for ReplaceBodyWithLoop { impl fold::Folder for ReplaceBodyWithLoop {
fn fold_item_kind(&mut self, i: ast::ItemKind) -> ast::ItemKind { fn fold_item_kind(&mut self, i: ast::ItemKind) -> ast::ItemKind {
match i { match i {
ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => { ast::ItemKind::Static(..) |
ast::ItemKind::Const(..) => {
self.within_static_or_const = true; self.within_static_or_const = true;
let ret = fold::noop_fold_item_kind(i, self); let ret = fold::noop_fold_item_kind(i, self);
self.within_static_or_const = false; self.within_static_or_const = false;
return ret; return ret;
} }
_ => { _ => fold::noop_fold_item_kind(i, self),
fold::noop_fold_item_kind(i, self)
}
} }
} }
@@ -656,11 +655,15 @@ impl fold::Folder for ReplaceBodyWithLoop {
fn fold_block(&mut self, b: P<ast::Block>) -> P<ast::Block> { fn fold_block(&mut self, b: P<ast::Block>) -> P<ast::Block> {
fn expr_to_block(rules: ast::BlockCheckMode, e: Option<P<ast::Expr>>) -> P<ast::Block> { fn expr_to_block(rules: ast::BlockCheckMode, e: Option<P<ast::Expr>>) -> P<ast::Block> {
P(ast::Block { P(ast::Block {
stmts: e.map(|e| ast::Stmt { stmts: e.map(|e| {
ast::Stmt {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
span: e.span, span: e.span,
node: ast::StmtKind::Expr(e), node: ast::StmtKind::Expr(e),
}).into_iter().collect(), }
})
.into_iter()
.collect(),
rules: rules, rules: rules,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
span: syntax_pos::DUMMY_SP, span: syntax_pos::DUMMY_SP,
@@ -721,9 +724,7 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
} }
blocks::FnLikeCode(fn_like) => { blocks::FnLikeCode(fn_like) => {
let (bccx, analysis_data) = let (bccx, analysis_data) =
borrowck::build_borrowck_dataflow_data_for_fn(tcx, borrowck::build_borrowck_dataflow_data_for_fn(tcx, fn_like.to_fn_parts(), &cfg);
fn_like.to_fn_parts(),
&cfg);
let lcfg = borrowck_dot::DataflowLabeller { let lcfg = borrowck_dot::DataflowLabeller {
inner: lcfg, inner: lcfg,
@@ -805,7 +806,8 @@ pub fn print_after_parsing(sess: &Session,
out, out,
annotation.pp_ann(), annotation.pp_ann(),
false) false)
}).unwrap() })
.unwrap()
} else { } else {
unreachable!(); unreachable!();
}; };
@@ -828,8 +830,15 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
let _ignore = dep_graph.in_ignore(); let _ignore = dep_graph.in_ignore();
if ppm.needs_analysis() { if ppm.needs_analysis() {
print_with_analysis(sess, ast_map, analysis, resolutions, print_with_analysis(sess,
crate_name, arenas, ppm, opt_uii, ofile); ast_map,
analysis,
resolutions,
crate_name,
arenas,
ppm,
opt_uii,
ofile);
return; return;
} }
@@ -892,8 +901,7 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
debug!("pretty printing source code {:?}", s); debug!("pretty printing source code {:?}", s);
let sess = annotation.sess(); let sess = annotation.sess();
let ast_map = annotation.ast_map().expect("--unpretty missing HIR map"); let ast_map = annotation.ast_map().expect("--unpretty missing HIR map");
let mut pp_state = let mut pp_state = pprust_hir::State::new_from_input(sess.codemap(),
pprust_hir::State::new_from_input(sess.codemap(),
sess.diagnostic(), sess.diagnostic(),
src_name.to_string(), src_name.to_string(),
&mut rdr, &mut rdr,
@@ -914,7 +922,8 @@ pub fn print_after_hir_lowering<'tcx, 'a: 'tcx>(sess: &'a Session,
}) })
} }
_ => unreachable!(), _ => unreachable!(),
}.unwrap(); }
.unwrap();
write_output(out, ofile); write_output(out, ofile);
} }
@@ -955,27 +964,28 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
let def_id = tcx.map.local_def_id(nodeid); let def_id = tcx.map.local_def_id(nodeid);
match ppm { match ppm {
PpmMir => write_mir_pretty(tcx, iter::once(def_id), &mut out), PpmMir => write_mir_pretty(tcx, iter::once(def_id), &mut out),
PpmMirCFG => { PpmMirCFG => write_mir_graphviz(tcx, iter::once(def_id), &mut out),
write_mir_graphviz(tcx, iter::once(def_id), &mut out)
}
_ => unreachable!(), _ => unreachable!(),
}?; }?;
} else { } else {
match ppm { match ppm {
PpmMir => write_mir_pretty(tcx, PpmMir => {
write_mir_pretty(tcx, tcx.mir_map.borrow().keys().into_iter(), &mut out)
}
PpmMirCFG => {
write_mir_graphviz(tcx,
tcx.mir_map.borrow().keys().into_iter(), tcx.mir_map.borrow().keys().into_iter(),
&mut out), &mut out)
PpmMirCFG => write_mir_graphviz(tcx, }
tcx.mir_map.borrow().keys().into_iter(),
&mut out),
_ => unreachable!(), _ => unreachable!(),
}?; }?;
} }
Ok(()) Ok(())
} }
PpmFlowGraph(mode) => { PpmFlowGraph(mode) => {
let nodeid = nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or \ let nodeid =
unique path suffix (b::c::d)"); nodeid.expect("`pretty flowgraph=..` needs NodeId (int) or unique path \
suffix (b::c::d)");
let node = tcx.map.find(nodeid).unwrap_or_else(|| { let node = tcx.map.find(nodeid).unwrap_or_else(|| {
tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid)) tcx.sess.fatal(&format!("--pretty flowgraph couldn't find id: {}", nodeid))
}); });
@@ -990,8 +1000,8 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
print_flowgraph(variants, tcx, code, mode, out) print_flowgraph(variants, tcx, code, mode, out)
} }
None => { None => {
let message = format!("--pretty=flowgraph needs block, fn, or method; got \ let message = format!("--pretty=flowgraph needs block, fn, or method; \
{:?}", got {:?}",
node); node);
// Point to what was found, if there's an accessible span. // Point to what was found, if there's an accessible span.
@@ -1004,7 +1014,9 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
} }
_ => unreachable!(), _ => unreachable!(),
} }
}), sess).unwrap(); }),
sess)
.unwrap();
write_output(out, ofile); write_output(out, ofile);
} }

View File

@@ -20,26 +20,11 @@ use libc::c_char;
// detection code will walk past the end of the feature array, // detection code will walk past the end of the feature array,
// leading to crashes. // leading to crashes.
const ARM_WHITELIST: &'static [&'static str] = &[ const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "vfp2\0", "vfp3\0", "vfp4\0"];
"neon\0",
"vfp2\0",
"vfp3\0",
"vfp4\0",
];
const X86_WHITELIST: &'static [&'static str] = &[ const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bmi2\0", "sse\0",
"avx\0", "sse2\0", "sse3\0", "sse4.1\0", "sse4.2\0",
"avx2\0", "ssse3\0", "tbm\0"];
"bmi\0",
"bmi2\0",
"sse\0",
"sse2\0",
"sse3\0",
"sse4.1\0",
"sse4.2\0",
"ssse3\0",
"tbm\0",
];
/// Add `target_feature = "..."` cfgs for a variety of platform /// Add `target_feature = "..."` cfgs for a variety of platform
/// specific features (SSE, NEON etc.). /// specific features (SSE, NEON etc.).

View File

@@ -86,8 +86,7 @@ impl Emitter for ExpectErrorEmitter {
fn errors(msgs: &[&str]) -> (Box<Emitter + Send>, usize) { fn errors(msgs: &[&str]) -> (Box<Emitter + Send>, usize) {
let v = msgs.iter().map(|m| m.to_string()).collect(); let v = msgs.iter().map(|m| m.to_string()).collect();
(box ExpectErrorEmitter { messages: v } as Box<Emitter + Send>, (box ExpectErrorEmitter { messages: v } as Box<Emitter + Send>, msgs.len())
msgs.len())
} }
fn test_env<F>(source_string: &str, fn test_env<F>(source_string: &str,
@@ -103,8 +102,12 @@ fn test_env<F>(source_string: &str,
let dep_graph = DepGraph::new(false); let dep_graph = DepGraph::new(false);
let _ignore = dep_graph.in_ignore(); let _ignore = dep_graph.in_ignore();
let cstore = Rc::new(CStore::new(&dep_graph)); let cstore = Rc::new(CStore::new(&dep_graph));
let sess = session::build_session_(options, &dep_graph, None, diagnostic_handler, let sess = session::build_session_(options,
Rc::new(CodeMap::new()), cstore.clone()); &dep_graph,
None,
diagnostic_handler,
Rc::new(CodeMap::new()),
cstore.clone());
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
let input = config::Input::Str { let input = config::Input::Str {
name: driver::anon_src(), name: driver::anon_src(),
@@ -112,9 +115,15 @@ fn test_env<F>(source_string: &str,
}; };
let krate = driver::phase_1_parse_input(&sess, &input).unwrap(); let krate = driver::phase_1_parse_input(&sess, &input).unwrap();
let driver::ExpansionResult { defs, resolutions, mut hir_forest, .. } = { let driver::ExpansionResult { defs, resolutions, mut hir_forest, .. } = {
driver::phase_2_configure_and_expand( driver::phase_2_configure_and_expand(&sess,
&sess, &cstore, krate, None, "test", None, MakeGlobMap::No, |_| Ok(()), &cstore,
).expect("phase 2 aborted") krate,
None,
"test",
None,
MakeGlobMap::No,
|_| Ok(()))
.expect("phase 2 aborted")
}; };
let _ignore = dep_graph.in_ignore(); let _ignore = dep_graph.in_ignore();
@@ -173,8 +182,16 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
region::ROOT_CODE_EXTENT); region::ROOT_CODE_EXTENT);
self.create_region_hierarchy(&RH { self.create_region_hierarchy(&RH {
id: node(1), id: node(1),
sub: &[RH { id: node(10), sub: &[] }, RH { id: node(11), sub: &[] }], sub: &[RH {
}, dscope); id: node(10),
sub: &[],
},
RH {
id: node(11),
sub: &[],
}],
},
dscope);
} }
#[allow(dead_code)] // this seems like it could be useful, even if we don't use it now #[allow(dead_code)] // this seems like it could be useful, even if we don't use it now
@@ -213,22 +230,16 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
hir::ItemStatic(..) | hir::ItemStatic(..) |
hir::ItemFn(..) | hir::ItemFn(..) |
hir::ItemForeignMod(..) | hir::ItemForeignMod(..) |
hir::ItemTy(..) => { hir::ItemTy(..) => None,
None
}
hir::ItemEnum(..) | hir::ItemEnum(..) |
hir::ItemStruct(..) | hir::ItemStruct(..) |
hir::ItemUnion(..) | hir::ItemUnion(..) |
hir::ItemTrait(..) | hir::ItemTrait(..) |
hir::ItemImpl(..) | hir::ItemImpl(..) |
hir::ItemDefaultImpl(..) => { hir::ItemDefaultImpl(..) => None,
None
}
hir::ItemMod(ref m) => { hir::ItemMod(ref m) => search_mod(this, m, idx, names),
search_mod(this, m, idx, names)
}
}; };
} }
} }
@@ -281,10 +292,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
self.infcx.tcx.mk_param(index, token::intern(&name[..])) self.infcx.tcx.mk_param(index, token::intern(&name[..]))
} }
pub fn re_early_bound(&self, pub fn re_early_bound(&self, index: u32, name: &'static str) -> &'tcx ty::Region {
index: u32,
name: &'static str)
-> &'tcx ty::Region {
let name = token::intern(name); let name = token::intern(name);
self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion { self.infcx.tcx.mk_region(ty::ReEarlyBound(ty::EarlyBoundRegion {
index: index, index: index,
@@ -292,7 +300,9 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
})) }))
} }
pub fn re_late_bound_with_debruijn(&self, id: u32, debruijn: ty::DebruijnIndex) pub fn re_late_bound_with_debruijn(&self,
id: u32,
debruijn: ty::DebruijnIndex)
-> &'tcx ty::Region { -> &'tcx ty::Region {
self.infcx.tcx.mk_region(ty::ReLateBound(debruijn, ty::BrAnon(id))) self.infcx.tcx.mk_region(ty::ReLateBound(debruijn, ty::BrAnon(id)))
} }
@@ -394,9 +404,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
self.assert_eq(t, t_lub); self.assert_eq(t, t_lub);
} }
Err(ref e) => { Err(ref e) => panic!("unexpected error in LUB: {}", e),
panic!("unexpected error in LUB: {}", e)
}
} }
} }
@@ -404,9 +412,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
pub fn check_glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_glb: Ty<'tcx>) { pub fn check_glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_glb: Ty<'tcx>) {
debug!("check_glb(t1={}, t2={}, t_glb={})", t1, t2, t_glb); debug!("check_glb(t1={}, t2={}, t_glb={})", t1, t2, t_glb);
match self.glb(t1, t2) { match self.glb(t1, t2) {
Err(e) => { Err(e) => panic!("unexpected error computing LUB: {:?}", e),
panic!("unexpected error computing LUB: {:?}", e)
}
Ok(InferOk { obligations, value: t }) => { Ok(InferOk { obligations, value: t }) => {
// FIXME(#32730) once obligations are being propagated, assert the right thing. // FIXME(#32730) once obligations are being propagated, assert the right thing.
assert!(obligations.is_empty()); assert!(obligations.is_empty());