Skip to content

Commit 5fdc812

Browse files
committed
auto merge of #11553 : klutzy/rust/rustc-cleanups, r=alexcrichton
2 parents 58a15f3 + b33d2fe commit 5fdc812

File tree

14 files changed

+187
-297
lines changed

14 files changed

+187
-297
lines changed

src/librustc/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ fn add_local_native_libraries(args: &mut ~[~str], sess: Session) {
11661166
fn add_upstream_rust_crates(args: &mut ~[~str], sess: Session,
11671167
dylib: bool, tmpdir: &Path) {
11681168
// Converts a library file-stem into a cc -l argument
1169-
fn unlib(config: @session::config, stem: &str) -> ~str {
1169+
fn unlib(config: @session::Config, stem: &str) -> ~str {
11701170
if stem.starts_with("lib") &&
11711171
config.os != abi::OsWin32 {
11721172
stem.slice(3, stem.len()).to_owned()

src/librustc/back/rpath.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {
3939

4040
debug!("preparing the RPATH!");
4141

42-
let sysroot = sess.filesearch.sysroot();
42+
let sysroot = sess.filesearch.sysroot;
4343
let output = out_filename;
4444
let libs = sess.cstore.get_used_crates(cstore::RequireDynamic);
4545
let libs = libs.move_iter().filter_map(|(_, l)| l.map(|p| p.clone())).collect();
@@ -55,7 +55,7 @@ pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> ~[~str] {
5555

5656
fn get_sysroot_absolute_rt_lib(sess: session::Session) -> Path {
5757
let r = filesearch::relative_target_lib_path(sess.opts.target_triple);
58-
let mut p = sess.filesearch.sysroot().join(&r);
58+
let mut p = sess.filesearch.sysroot.join(&r);
5959
p.push(os::dll_filename("rustrt"));
6060
p
6161
}

src/librustc/driver/driver.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ pub enum PpMode {
6262
*/
6363
pub fn anon_src() -> @str { @"<anon>" }
6464
65-
pub fn source_name(input: &input) -> @str {
65+
pub fn source_name(input: &Input) -> @str {
6666
match *input {
6767
// FIXME (#9639): This needs to handle non-utf8 paths
68-
file_input(ref ifile) => ifile.as_str().unwrap().to_managed(),
69-
str_input(_) => anon_src()
68+
FileInput(ref ifile) => ifile.as_str().unwrap().to_managed(),
69+
StrInput(_) => anon_src()
7070
}
7171
}
7272
@@ -133,22 +133,22 @@ fn parse_cfgspecs(cfgspecs: ~[~str], demitter: @diagnostic::Emitter)
133133
}).collect::<ast::CrateConfig>()
134134
}
135135

136-
pub enum input {
136+
pub enum Input {
137137
/// Load source from file
138-
file_input(Path),
138+
FileInput(Path),
139139
/// The string is the source
140140
// FIXME (#2319): Don't really want to box the source string
141-
str_input(@str)
141+
StrInput(@str)
142142
}
143143

144-
pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &input)
144+
pub fn phase_1_parse_input(sess: Session, cfg: ast::CrateConfig, input: &Input)
145145
-> ast::Crate {
146146
time(sess.time_passes(), "parsing", (), |_| {
147147
match *input {
148-
file_input(ref file) => {
148+
FileInput(ref file) => {
149149
parse::parse_crate_from_file(&(*file), cfg.clone(), sess.parse_sess)
150150
}
151-
str_input(src) => {
151+
StrInput(src) => {
152152
parse::parse_crate_from_source_str(
153153
anon_src(), src, cfg.clone(), sess.parse_sess)
154154
}
@@ -444,7 +444,7 @@ pub fn stop_after_phase_5(sess: Session) -> bool {
444444
return false;
445445
}
446446

447-
fn write_out_deps(sess: Session, input: &input, outputs: &OutputFilenames, crate: &ast::Crate)
447+
fn write_out_deps(sess: Session, input: &Input, outputs: &OutputFilenames, crate: &ast::Crate)
448448
{
449449
let lm = link::build_link_meta(sess, crate.attrs, &outputs.obj_filename,
450450
&mut ::util::sha2::Sha256::new());
@@ -460,12 +460,12 @@ fn write_out_deps(sess: Session, input: &input, outputs: &OutputFilenames, crate
460460
(true, Some(ref filename)) => filename.clone(),
461461
// Use default filename: crate source filename with extension replaced by ".d"
462462
(true, None) => match *input {
463-
file_input(ref input_path) => {
463+
FileInput(ref input_path) => {
464464
let filestem = input_path.filestem().expect("input file must have stem");
465465
let filename = out_filenames[0].dir_path().join(filestem).with_extension("d");
466466
filename
467467
},
468-
str_input(..) => {
468+
StrInput(..) => {
469469
sess.warn("can not write --dep-info without a filename when compiling stdin.");
470470
return;
471471
},
@@ -495,7 +495,7 @@ fn write_out_deps(sess: Session, input: &input, outputs: &OutputFilenames, crate
495495
}
496496
}
497497

498-
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
498+
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &Input,
499499
outdir: &Option<Path>, output: &Option<Path>) {
500500
// We need nested scopes here, because the intermediate results can keep
501501
// large chunks of memory alive and we want to free them as soon as
@@ -587,7 +587,7 @@ impl pprust::PpAnn for TypedAnnotation {
587587

588588
pub fn pretty_print_input(sess: Session,
589589
cfg: ast::CrateConfig,
590-
input: &input,
590+
input: &Input,
591591
ppm: PpMode) {
592592
let crate = phase_1_parse_input(sess, cfg.clone(), input);
593593

@@ -664,9 +664,9 @@ static architecture_abis : &'static [(&'static str, abi::Architecture)] = &'stat
664664

665665
("mips", abi::Mips)];
666666

667-
pub fn build_target_config(sopts: @session::options,
667+
pub fn build_target_config(sopts: @session::Options,
668668
demitter: @diagnostic::Emitter)
669-
-> @session::config {
669+
-> @session::Config {
670670
let os = match get_os(sopts.target_triple) {
671671
Some(os) => os,
672672
None => early_error(demitter, "unknown operating system")
@@ -689,7 +689,7 @@ pub fn build_target_config(sopts: @session::options,
689689
abi::Arm => arm::get_target_strs(target_triple, os),
690690
abi::Mips => mips::get_target_strs(target_triple, os)
691691
};
692-
let target_cfg = @session::config {
692+
let target_cfg = @session::Config {
693693
os: os,
694694
arch: arch,
695695
target_strs: target_strs,
@@ -714,7 +714,7 @@ pub fn host_triple() -> ~str {
714714
pub fn build_session_options(binary: ~str,
715715
matches: &getopts::Matches,
716716
demitter: @diagnostic::Emitter)
717-
-> @session::options {
717+
-> @session::Options {
718718
let mut outputs = ~[];
719719
if matches.opt_present("rlib") {
720720
outputs.push(session::OutputRlib)
@@ -862,7 +862,7 @@ pub fn build_session_options(binary: ~str,
862862
matches.opt_present("crate-name"),
863863
matches.opt_present("crate-file-name"));
864864

865-
let sopts = @session::options {
865+
let sopts = @session::Options {
866866
outputs: outputs,
867867
gc: gc,
868868
optimize: opt_level,
@@ -895,7 +895,7 @@ pub fn build_session_options(binary: ~str,
895895
return sopts;
896896
}
897897

898-
pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
898+
pub fn build_session(sopts: @session::Options, demitter: @diagnostic::Emitter)
899899
-> Session {
900900
let codemap = @codemap::CodeMap::new();
901901
let diagnostic_handler =
@@ -905,7 +905,7 @@ pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
905905
build_session_(sopts, codemap, demitter, span_diagnostic_handler)
906906
}
907907

908-
pub fn build_session_(sopts: @session::options,
908+
pub fn build_session_(sopts: @session::Options,
909909
cm: @codemap::CodeMap,
910910
demitter: @diagnostic::Emitter,
911911
span_diagnostic_handler: @diagnostic::SpanHandler)
@@ -914,7 +914,7 @@ pub fn build_session_(sopts: @session::options,
914914
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
915915
cm);
916916
let cstore = @CStore::new(token::get_ident_interner());
917-
let filesearch = filesearch::mk_filesearch(
917+
let filesearch = @filesearch::FileSearch::new(
918918
&sopts.maybe_sysroot,
919919
sopts.target_triple,
920920
sopts.addl_lib_search_paths);
@@ -1046,7 +1046,7 @@ pub struct OutputFilenames {
10461046
obj_filename: Path
10471047
}
10481048

1049-
pub fn build_output_filenames(input: &input,
1049+
pub fn build_output_filenames(input: &Input,
10501050
odir: &Option<Path>,
10511051
ofile: &Option<Path>,
10521052
attrs: &[ast::Attribute],
@@ -1074,15 +1074,15 @@ pub fn build_output_filenames(input: &input,
10741074
let dirpath = match *odir {
10751075
Some(ref d) => (*d).clone(),
10761076
None => match *input {
1077-
str_input(_) => os::getcwd(),
1078-
file_input(ref ifile) => (*ifile).dir_path()
1077+
StrInput(_) => os::getcwd(),
1078+
FileInput(ref ifile) => (*ifile).dir_path()
10791079
}
10801080
};
10811081

10821082
let mut stem = match *input {
10831083
// FIXME (#9639): This needs to handle non-utf8 paths
1084-
file_input(ref ifile) => (*ifile).filestem_str().unwrap().to_managed(),
1085-
str_input(_) => @"rust_out"
1084+
FileInput(ref ifile) => (*ifile).filestem_str().unwrap().to_managed(),
1085+
StrInput(_) => @"rust_out"
10861086
};
10871087

10881088
// If a crateid is present, we use it as the link name

src/librustc/driver/session.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax;
3131
use std::cell::{Cell, RefCell};
3232
use std::hashmap::{HashMap,HashSet};
3333

34-
pub struct config {
34+
pub struct Config {
3535
os: abi::Os,
3636
arch: abi::Architecture,
3737
target_strs: target_strs::t,
@@ -134,7 +134,7 @@ pub enum OptLevel {
134134
}
135135

136136
#[deriving(Clone)]
137-
pub struct options {
137+
pub struct Options {
138138
// The crate config requested for the session, which may be combined
139139
// with additional crate configurations during the compile process
140140
outputs: ~[OutputStyle],
@@ -176,11 +176,6 @@ pub struct options {
176176
print_metas: (bool, bool, bool),
177177
}
178178

179-
pub struct crate_metadata {
180-
name: ~str,
181-
data: ~[u8]
182-
}
183-
184179
// The type of entry function, so
185180
// users can have their own entry
186181
// functions that don't start a
@@ -201,8 +196,8 @@ pub enum OutputStyle {
201196
}
202197

203198
pub struct Session_ {
204-
targ_cfg: @config,
205-
opts: @options,
199+
targ_cfg: @Config,
200+
opts: @Options,
206201
cstore: @metadata::cstore::CStore,
207202
parse_sess: @ParseSess,
208203
codemap: @codemap::CodeMap,
@@ -375,8 +370,8 @@ impl Session_ {
375370
}
376371

377372
/// Some reasonable defaults
378-
pub fn basic_options() -> @options {
379-
@options {
373+
pub fn basic_options() -> @Options {
374+
@Options {
380375
outputs: ~[],
381376
gc: false,
382377
optimize: No,
@@ -413,7 +408,7 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: || -> ~str) -> T {
413408
diagnostic::expect(sess.diagnostic(), opt, msg)
414409
}
415410

416-
pub fn building_library(options: &options, crate: &ast::Crate) -> bool {
411+
pub fn building_library(options: &Options, crate: &ast::Crate) -> bool {
417412
if options.test { return false }
418413
for output in options.outputs.iter() {
419414
match *output {

src/librustc/lib.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,9 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
255255
let ifile = matches.free[0].as_slice();
256256
if "-" == ifile {
257257
let src = str::from_utf8_owned(io::stdin().read_to_end());
258-
d::str_input(src.to_managed())
258+
d::StrInput(src.to_managed())
259259
} else {
260-
d::file_input(Path::new(ifile))
260+
d::FileInput(Path::new(ifile))
261261
}
262262
}
263263
_ => d::early_error(demitter, "multiple input filenames provided")
@@ -281,12 +281,12 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
281281
let ls = matches.opt_present("ls");
282282
if ls {
283283
match input {
284-
d::file_input(ref ifile) => {
284+
d::FileInput(ref ifile) => {
285285
let mut stdout = io::stdout();
286286
d::list_metadata(sess, &(*ifile),
287287
&mut stdout as &mut io::Writer);
288288
}
289-
d::str_input(_) => {
289+
d::StrInput(_) => {
290290
d::early_error(demitter, "can not list metadata for stdin");
291291
}
292292
}
@@ -332,12 +332,12 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
332332
}
333333

334334
fn parse_crate_attrs(sess: session::Session,
335-
input: &d::input) -> ~[ast::Attribute] {
335+
input: &d::Input) -> ~[ast::Attribute] {
336336
match *input {
337-
d::file_input(ref ifile) => {
337+
d::FileInput(ref ifile) => {
338338
parse::parse_crate_attrs_from_file(ifile, ~[], sess.parse_sess)
339339
}
340-
d::str_input(src) => {
340+
d::StrInput(src) => {
341341
parse::parse_crate_attrs_from_source_str(
342342
d::anon_src(), src, ~[], sess.parse_sess)
343343
}

0 commit comments

Comments
 (0)