Skip to content

Commit

Permalink
De-implicit-self librustc
Browse files Browse the repository at this point in the history
  • Loading branch information
bstrie committed Feb 22, 2013
1 parent cec1f38 commit 4a85389
Show file tree
Hide file tree
Showing 26 changed files with 626 additions and 569 deletions.
86 changes: 48 additions & 38 deletions src/librustc/driver/session.rs
Expand Up @@ -165,49 +165,49 @@ pub struct Session_ {
pub type Session = @Session_;

pub impl Session {
fn span_fatal(sp: span, msg: ~str) -> ! {
fn span_fatal(&self, sp: span, msg: ~str) -> ! {
self.span_diagnostic.span_fatal(sp, msg)
}
fn fatal(msg: ~str) -> ! {
fn fatal(&self, msg: ~str) -> ! {
self.span_diagnostic.handler().fatal(msg)
}
fn span_err(sp: span, msg: ~str) {
fn span_err(&self, sp: span, msg: ~str) {
self.span_diagnostic.span_err(sp, msg)
}
fn err(msg: ~str) {
fn err(&self, msg: ~str) {
self.span_diagnostic.handler().err(msg)
}
fn has_errors() -> bool {
fn has_errors(&self) -> bool {
self.span_diagnostic.handler().has_errors()
}
fn abort_if_errors() {
fn abort_if_errors(&self) {
self.span_diagnostic.handler().abort_if_errors()
}
fn span_warn(sp: span, msg: ~str) {
fn span_warn(&self, sp: span, msg: ~str) {
self.span_diagnostic.span_warn(sp, msg)
}
fn warn(msg: ~str) {
fn warn(&self, msg: ~str) {
self.span_diagnostic.handler().warn(msg)
}
fn span_note(sp: span, msg: ~str) {
fn span_note(&self, sp: span, msg: ~str) {
self.span_diagnostic.span_note(sp, msg)
}
fn note(msg: ~str) {
fn note(&self, msg: ~str) {
self.span_diagnostic.handler().note(msg)
}
fn span_bug(sp: span, msg: ~str) -> ! {
fn span_bug(&self, sp: span, msg: ~str) -> ! {
self.span_diagnostic.span_bug(sp, msg)
}
fn bug(msg: ~str) -> ! {
fn bug(&self, msg: ~str) -> ! {
self.span_diagnostic.handler().bug(msg)
}
fn span_unimpl(sp: span, msg: ~str) -> ! {
fn span_unimpl(&self, sp: span, msg: ~str) -> ! {
self.span_diagnostic.span_unimpl(sp, msg)
}
fn unimpl(msg: ~str) -> ! {
fn unimpl(&self, msg: ~str) -> ! {
self.span_diagnostic.handler().unimpl(msg)
}
fn span_lint_level(level: lint::level, sp: span, +msg: ~str) {
fn span_lint_level(&self, level: lint::level, sp: span, +msg: ~str) {
match level {
lint::allow => { },
lint::warn => self.span_warn(sp, msg),
Expand All @@ -216,7 +216,7 @@ pub impl Session {
}
}
}
fn span_lint(lint_mode: lint::lint,
fn span_lint(&self, lint_mode: lint::lint,
expr_id: ast::node_id,
item_id: ast::node_id,
span: span,
Expand All @@ -225,45 +225,55 @@ pub impl Session {
self.lint_settings, lint_mode, expr_id, item_id);
self.span_lint_level(level, span, msg);
}
fn next_node_id() -> ast::node_id {
fn next_node_id(&self) -> ast::node_id {
return syntax::parse::next_node_id(self.parse_sess);
}
fn diagnostic() -> diagnostic::span_handler {
fn diagnostic(&self) -> diagnostic::span_handler {
self.span_diagnostic
}
fn debugging_opt(opt: uint) -> bool {
fn debugging_opt(&self, opt: uint) -> bool {
(self.opts.debugging_opts & opt) != 0u
}
// This exists to help with refactoring to eliminate impossible
// cases later on
fn impossible_case(sp: span, msg: &str) -> ! {
fn impossible_case(&self, sp: span, msg: &str) -> ! {
self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
}
fn verbose() -> bool { self.debugging_opt(verbose) }
fn time_passes() -> bool { self.debugging_opt(time_passes) }
fn count_llvm_insns() -> bool { self.debugging_opt(count_llvm_insns) }
fn count_type_sizes() -> bool { self.debugging_opt(count_type_sizes) }
fn time_llvm_passes() -> bool { self.debugging_opt(time_llvm_passes) }
fn trans_stats() -> bool { self.debugging_opt(trans_stats) }
fn meta_stats() -> bool { self.debugging_opt(meta_stats) }
fn no_asm_comments() -> bool { self.debugging_opt(no_asm_comments) }
fn no_verify() -> bool { self.debugging_opt(no_verify) }
fn trace() -> bool { self.debugging_opt(trace) }
fn coherence() -> bool { self.debugging_opt(coherence) }
fn borrowck_stats() -> bool { self.debugging_opt(borrowck_stats) }
fn borrowck_note_pure() -> bool { self.debugging_opt(borrowck_note_pure) }
fn borrowck_note_loan() -> bool { self.debugging_opt(borrowck_note_loan) }
fn no_monomorphic_collapse() -> bool {
fn verbose(&self) -> bool { self.debugging_opt(verbose) }
fn time_passes(&self) -> bool { self.debugging_opt(time_passes) }
fn count_llvm_insns(&self) -> bool {
self.debugging_opt(count_llvm_insns)
}
fn count_type_sizes(&self) -> bool {
self.debugging_opt(count_type_sizes)
}
fn time_llvm_passes(&self) -> bool {
self.debugging_opt(time_llvm_passes)
}
fn trans_stats(&self) -> bool { self.debugging_opt(trans_stats) }
fn meta_stats(&self) -> bool { self.debugging_opt(meta_stats) }
fn no_asm_comments(&self) -> bool { self.debugging_opt(no_asm_comments) }
fn no_verify(&self) -> bool { self.debugging_opt(no_verify) }
fn trace(&self) -> bool { self.debugging_opt(trace) }
fn coherence(&self) -> bool { self.debugging_opt(coherence) }
fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) }
fn borrowck_note_pure(&self) -> bool {
self.debugging_opt(borrowck_note_pure)
}
fn borrowck_note_loan(&self) -> bool {
self.debugging_opt(borrowck_note_loan)
}
fn no_monomorphic_collapse(&self) -> bool {
self.debugging_opt(no_monomorphic_collapse)
}

fn str_of(id: ast::ident) -> @~str {
fn str_of(&self, id: ast::ident) -> @~str {
self.parse_sess.interner.get(id)
}
fn ident_of(+st: ~str) -> ast::ident {
fn ident_of(&self, +st: ~str) -> ast::ident {
self.parse_sess.interner.intern(@st)
}
fn intr() -> @syntax::parse::token::ident_interner {
fn intr(&self) -> @syntax::parse::token::ident_interner {
self.parse_sess.interner
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/metadata/filesearch.rs
Expand Up @@ -29,10 +29,10 @@ pub fn pick_file(file: Path, path: &Path) -> Option<Path> {
}

pub trait FileSearch {
fn sysroot() -> Path;
fn lib_search_paths() -> ~[Path];
fn get_target_lib_path() -> Path;
fn get_target_lib_file_path(file: &Path) -> Path;
fn sysroot(&self) -> Path;
fn lib_search_paths(&self) -> ~[Path];
fn get_target_lib_path(&self) -> Path;
fn get_target_lib_file_path(&self, file: &Path) -> Path;
}

pub fn mk_filesearch(maybe_sysroot: Option<Path>,
Expand All @@ -44,8 +44,8 @@ pub fn mk_filesearch(maybe_sysroot: Option<Path>,
target_triple: ~str
}
impl FileSearch for FileSearchImpl {
fn sysroot() -> Path { /*bad*/copy self.sysroot }
fn lib_search_paths() -> ~[Path] {
fn sysroot(&self) -> Path { /*bad*/copy self.sysroot }
fn lib_search_paths(&self) -> ~[Path] {
let mut paths = /*bad*/copy self.addl_lib_search_paths;

paths.push(
Expand All @@ -61,10 +61,10 @@ pub fn mk_filesearch(maybe_sysroot: Option<Path>,
}
paths
}
fn get_target_lib_path() -> Path {
fn get_target_lib_path(&self) -> Path {
make_target_lib_path(&self.sysroot, self.target_triple)
}
fn get_target_lib_file_path(file: &Path) -> Path {
fn get_target_lib_file_path(&self, file: &Path) -> Path {
self.get_target_lib_path().push_rel(file)
}
}
Expand Down

5 comments on commit 4a85389

@bors
Copy link
Contributor

@bors bors commented on 4a85389 Feb 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at bstrie@4a85389

@bors
Copy link
Contributor

@bors bors commented on 4a85389 Feb 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bstrie/rust/deimpself = 4a85389 into auto

@bors
Copy link
Contributor

@bors bors commented on 4a85389 Feb 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bstrie/rust/deimpself = 4a85389 merged ok, testing candidate = ba7a870

@bors
Copy link
Contributor

@bors bors commented on 4a85389 Feb 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 4a85389 Feb 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = ba7a870

Please sign in to comment.