Skip to content

Commit f30a9b3

Browse files
committed
rustc::driver: Capitalize structs and enums
driver::session::crate_metadata is unused; removed.
1 parent 80a3f45 commit f30a9b3

File tree

9 files changed

+55
-60
lines changed

9 files changed

+55
-60
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/driver/driver.rs

+26-26
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)
@@ -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
}

src/librustdoc/core.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ pub struct CrateAnalysis {
4242
fn get_ast_and_resolve(cpath: &Path,
4343
libs: HashSet<Path>, cfgs: ~[~str]) -> (DocContext, CrateAnalysis) {
4444
use syntax::codemap::dummy_spanned;
45-
use rustc::driver::driver::{file_input, build_configuration,
45+
use rustc::driver::driver::{FileInput, build_configuration,
4646
phase_1_parse_input,
4747
phase_2_configure_and_expand,
4848
phase_3_run_analysis_passes};
4949

5050
let parsesess = parse::new_parse_sess(None);
51-
let input = file_input(cpath.clone());
51+
let input = FileInput(cpath.clone());
5252

53-
let sessopts = @driver::session::options {
53+
let sessopts = @driver::session::Options {
5454
binary: ~"rustdoc",
5555
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
5656
addl_lib_search_paths: @RefCell::new(libs),

src/librustdoc/test.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ use visit_ast::RustdocVisitor;
3434

3535
pub fn run(input: &str, matches: &getopts::Matches) -> int {
3636
let parsesess = parse::new_parse_sess(None);
37-
let input = driver::file_input(Path::new(input));
37+
let input = driver::FileInput(Path::new(input));
3838
let libs = matches.opt_strs("L").map(|s| Path::new(s.as_slice()));
3939
let libs = @RefCell::new(libs.move_iter().collect());
4040

41-
let sessopts = @session::options {
41+
let sessopts = @session::Options {
4242
binary: ~"rustdoc",
4343
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
4444
addl_lib_search_paths: libs,
@@ -97,9 +97,9 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
9797
fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) {
9898
let test = maketest(test, cratename);
9999
let parsesess = parse::new_parse_sess(None);
100-
let input = driver::str_input(test);
100+
let input = driver::StrInput(test);
101101

102-
let sessopts = @session::options {
102+
let sessopts = @session::Options {
103103
binary: ~"rustdoctest",
104104
maybe_sysroot: Some(@os::self_exe_path().unwrap().dir_path()),
105105
addl_lib_search_paths: @RefCell::new(libs),

src/librustpkg/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ impl<'a> PkgScript<'a> {
107107
// Build the rustc session data structures to pass
108108
// to the compiler
109109
debug!("pkgscript parse: {}", sysroot.display());
110-
let options = @session::options {
110+
let options = @session::Options {
111111
binary: binary,
112112
maybe_sysroot: Some(@sysroot),
113113
outputs: ~[session::OutputExecutable],
114114
.. (*session::basic_options()).clone()
115115
};
116-
let input = driver::file_input(script.clone());
116+
let input = driver::FileInput(script.clone());
117117
let sess = driver::build_session(options,
118118
@diagnostic::DefaultEmitter as
119119
@diagnostic::Emitter);
@@ -146,7 +146,7 @@ impl<'a> PkgScript<'a> {
146146
let (crate, ast_map) = self.crate_and_map.take_unwrap();
147147
let crate = util::ready_crate(sess, crate);
148148
debug!("Building output filenames with script name {}",
149-
driver::source_name(&driver::file_input(self.input.clone())));
149+
driver::source_name(&driver::FileInput(self.input.clone())));
150150
let exe = self.build_dir.join("pkg" + util::exe_suffix());
151151
util::compile_crate_from_input(&self.input,
152152
exec,

src/librustpkg/util.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub fn compile_input(context: &BuildContext,
171171
opt: session::OptLevel,
172172
what: OutputType) -> Option<Path> {
173173
assert!(in_file.components().nth(1).is_some());
174-
let input = driver::file_input(in_file.clone());
174+
let input = driver::FileInput(in_file.clone());
175175
debug!("compile_input: {} / {:?}", in_file.display(), what);
176176
// tjc: by default, use the package ID name as the link name
177177
// not sure if we should support anything else
@@ -228,7 +228,7 @@ pub fn compile_input(context: &BuildContext,
228228

229229
debug!("Output type = {:?}", output_type);
230230

231-
let options = @session::options {
231+
let options = @session::Options {
232232
optimize: opt,
233233
test: what == Test || what == Bench,
234234
maybe_sysroot: Some(sysroot_to_use),
@@ -373,7 +373,7 @@ pub fn compile_crate_from_input(input: &Path,
373373

374374
// bad copy
375375
debug!("out_dir = {}", out_dir.display());
376-
let file_input = driver::file_input(input.clone());
376+
let file_input = driver::FileInput(input.clone());
377377
let mut outputs = driver::build_output_filenames(&file_input,
378378
&Some(out_dir.clone()), &None,
379379
crate.attrs, sess);

src/libsyntax/parse/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ mod test {
418418

419419
#[test] fn string_to_tts_1 () {
420420
let tts = string_to_tts(@"fn a (b : int) { b; }");
421-
assert_eq!(to_json_str(@tts),
421+
assert_eq!(to_json_str(&tts),
422422
~"[\
423423
{\
424424
\"variant\":\"TTTok\",\

0 commit comments

Comments
 (0)