Skip to content

Commit 03584a2

Browse files
committed
Less cfg's
1 parent bffc973 commit 03584a2

File tree

4 files changed

+25
-43
lines changed

4 files changed

+25
-43
lines changed

src/librustc_driver/driver.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ pub fn compile_input(sess: &Session,
7373
output: &Option<PathBuf>,
7474
addl_plugins: Option<Vec<String>>,
7575
control: &CompileController) -> CompileResult {
76-
#[cfg(feature="llvm")]
7776
use rustc_trans::back::write::OngoingCrateTranslation;
78-
#[cfg(not(feature="llvm"))]
79-
type OngoingCrateTranslation = ();
8077

8178
macro_rules! controller_entry_point {
8279
($point: ident, $tsess: expr, $make_state: expr, $phase_result: expr) => {{
@@ -393,7 +390,6 @@ pub struct CompileState<'a, 'tcx: 'a> {
393390
pub resolutions: Option<&'a Resolutions>,
394391
pub analysis: Option<&'a ty::CrateAnalysis>,
395392
pub tcx: Option<TyCtxt<'a, 'tcx, 'tcx>>,
396-
#[cfg(feature="llvm")]
397393
pub trans: Option<&'a trans::CrateTranslation>,
398394
}
399395

@@ -420,7 +416,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
420416
resolutions: None,
421417
analysis: None,
422418
tcx: None,
423-
#[cfg(feature="llvm")]
424419
trans: None,
425420
}
426421
}
@@ -942,7 +937,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
942937
mir::provide(&mut local_providers);
943938
reachable::provide(&mut local_providers);
944939
rustc_privacy::provide(&mut local_providers);
945-
#[cfg(feature="llvm")]
946940
trans::provide(&mut local_providers);
947941
typeck::provide(&mut local_providers);
948942
ty::provide(&mut local_providers);
@@ -955,7 +949,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
955949

956950
let mut extern_providers = ty::maps::Providers::default();
957951
cstore::provide(&mut extern_providers);
958-
#[cfg(feature="llvm")]
959952
trans::provide(&mut extern_providers);
960953
ty::provide_extern(&mut extern_providers);
961954
traits::provide_extern(&mut extern_providers);

src/librustc_driver/lib.rs

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ use pretty::{PpMode, UserIdentifiedItem};
7171
use rustc_resolve as resolve;
7272
use rustc_save_analysis as save;
7373
use rustc_save_analysis::DumpHandler;
74-
#[cfg(feature="llvm")]
75-
use rustc_trans::back::write::{RELOC_MODEL_ARGS, CODE_GEN_MODEL_ARGS};
7674
use rustc::dep_graph::DepGraph;
7775
use rustc::session::{self, config, Session, build_session, CompileResult};
7876
use rustc::session::CompileIncomplete;
@@ -207,6 +205,25 @@ impl MetadataLoaderTrait for NoLLvmMetadataLoader {
207205
}
208206
}
209207

208+
#[cfg(feature="llvm")]
209+
mod rustc_trans {
210+
use rustc::ty::maps::Providers;
211+
pub fn init(_sess: &Session) {}
212+
pub fn enable_llvm_debug() {}
213+
pub fn provide(_providers: &mut Providers) {}
214+
pub struct CrateTranslation(());
215+
pub mod back {
216+
pub mod write {
217+
pub struct OngoingCrateTranslation(());
218+
}
219+
}
220+
mod diagnostics {
221+
register_long_diagnostics! {}
222+
}
223+
224+
pub use diagnostics::DIAGNOSTICS;
225+
}
226+
210227
// Parse args and run the compiler. This is the primary entry point for rustc.
211228
// See comments on CompilerCalls below for details about the callbacks argument.
212229
// The FileLoader provides a way to load files from sources other than the file system.
@@ -232,7 +249,6 @@ pub fn run_compiler<'a>(args: &[String],
232249
let (sopts, cfg) = config::build_session_options_and_crate_config(&matches);
233250

234251
if sopts.debugging_opts.debug_llvm {
235-
#[cfg(feature="llvm")]
236252
rustc_trans::enable_llvm_debug();
237253
}
238254

@@ -262,7 +278,6 @@ pub fn run_compiler<'a>(args: &[String],
262278
let mut sess = session::build_session_with_codemap(
263279
sopts, &dep_graph, input_file_path, descriptions, cstore.clone(), codemap, emitter_dest,
264280
);
265-
#[cfg(feature="llvm")]
266281
rustc_trans::init(&sess);
267282
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
268283

@@ -544,7 +559,6 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
544559
None,
545560
descriptions.clone(),
546561
cstore.clone());
547-
#[cfg(feature="llvm")]
548562
rustc_trans::init(&sess);
549563
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
550564
let mut cfg = config::build_configuration(&sess, cfg.clone());
@@ -803,15 +817,15 @@ impl RustcDefaultCalls {
803817
PrintRequest::RelocationModels => {
804818
println!("Available relocation models:");
805819
#[cfg(feature="llvm")]
806-
for &(name, _) in RELOC_MODEL_ARGS.iter() {
820+
for &(name, _) in rustc_trans::back::write::RELOC_MODEL_ARGS.iter() {
807821
println!(" {}", name);
808822
}
809823
println!("");
810824
}
811825
PrintRequest::CodeModels => {
812826
println!("Available code models:");
813827
#[cfg(feature="llvm")]
814-
for &(name, _) in CODE_GEN_MODEL_ARGS.iter(){
828+
for &(name, _) in rustc_trans::back::write::CODE_GEN_MODEL_ARGS.iter(){
815829
println!(" {}", name);
816830
}
817831
println!("");
@@ -1285,7 +1299,6 @@ pub fn diagnostics_registry() -> errors::registry::Registry {
12851299
all_errors.extend_from_slice(&rustc_borrowck::DIAGNOSTICS);
12861300
all_errors.extend_from_slice(&rustc_resolve::DIAGNOSTICS);
12871301
all_errors.extend_from_slice(&rustc_privacy::DIAGNOSTICS);
1288-
#[cfg(feature="llvm")]
12891302
all_errors.extend_from_slice(&rustc_trans::DIAGNOSTICS);
12901303
all_errors.extend_from_slice(&rustc_const_eval::DIAGNOSTICS);
12911304
all_errors.extend_from_slice(&rustc_metadata::DIAGNOSTICS);

src/librustc_driver/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ fn test_env<F>(source_string: &str,
114114
diagnostic_handler,
115115
Rc::new(CodeMap::new(FilePathMapping::empty())),
116116
cstore.clone());
117-
#[cfg(feature="llvm")]
118117
rustc_trans::init(&sess);
119118
rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
120119
let input = config::Input::Str {

src/librustc_trans_utils/link.rs

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::session::config::{self, /*NoDebugInfo,*/ OutputFilenames, Input, OutputType};
12-
/*use rustc::session::filesearch;
13-
use rustc::session::search_paths::PathKind;
14-
*/use rustc::session::Session;
15-
use rustc::middle::cstore;/*::{self, LinkMeta, NativeLibrary, LibSource, LinkagePreference,
16-
NativeLibraryKind};*/
17-
/*use rustc::middle::dependency_format::Linkage;
18-
use rustc::util::common::time;
19-
use rustc::util::fs::fix_windows_verbatim_for_gcc;
20-
use rustc::dep_graph::{DepKind, DepNode};
21-
use rustc::hir::def_id::CrateNum;
22-
use rustc::hir::svh::Svh;
23-
use rustc_back::tempdir::TempDir;
24-
use rustc_back::{PanicStrategy, RelroLevel};
25-
use rustc_incremental::IncrementalHashesMap;*/
26-
27-
/*use std::ascii;
28-
use std::char;
29-
use std::env;
30-
use std::ffi::OsString;
31-
use std::fs;
32-
use std::io::{self, Read, Write};
33-
use std::mem;
34-
*/use std::path::PathBuf;/*{Path, PathBuf};
35-
use std::process::Command;
36-
use std::str;*/
11+
use rustc::session::config::{self, OutputFilenames, Input, OutputType};
12+
use rustc::session::Session;
13+
use rustc::middle::cstore;
14+
use std::path::PathBuf;
3715
use syntax::ast;
38-
//use syntax::attr;
3916
use syntax_pos::Span;
4017

4118
pub fn find_crate_name(sess: Option<&Session>,

0 commit comments

Comments
 (0)