Skip to content

Commit a410652

Browse files
committed
librustc: Remove "base types" from the language.
1 parent b85158e commit a410652

File tree

8 files changed

+141
-148
lines changed

8 files changed

+141
-148
lines changed

src/librustc/driver/session.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -163,50 +163,50 @@ pub struct Session_ {
163163

164164
pub type Session = @Session_;
165165

166-
pub impl Session {
167-
fn span_fatal(&self, sp: span, msg: ~str) -> ! {
166+
pub impl Session_ {
167+
fn span_fatal(@self, sp: span, msg: ~str) -> ! {
168168
self.span_diagnostic.span_fatal(sp, msg)
169169
}
170-
fn fatal(&self, msg: ~str) -> ! {
170+
fn fatal(@self, msg: ~str) -> ! {
171171
self.span_diagnostic.handler().fatal(msg)
172172
}
173-
fn span_err(&self, sp: span, msg: ~str) {
173+
fn span_err(@self, sp: span, msg: ~str) {
174174
self.span_diagnostic.span_err(sp, msg)
175175
}
176-
fn err(&self, msg: ~str) {
176+
fn err(@self, msg: ~str) {
177177
self.span_diagnostic.handler().err(msg)
178178
}
179-
fn has_errors(&self) -> bool {
179+
fn has_errors(@self) -> bool {
180180
self.span_diagnostic.handler().has_errors()
181181
}
182-
fn abort_if_errors(&self) {
182+
fn abort_if_errors(@self) {
183183
self.span_diagnostic.handler().abort_if_errors()
184184
}
185-
fn span_warn(&self, sp: span, msg: ~str) {
185+
fn span_warn(@self, sp: span, msg: ~str) {
186186
self.span_diagnostic.span_warn(sp, msg)
187187
}
188-
fn warn(&self, msg: ~str) {
188+
fn warn(@self, msg: ~str) {
189189
self.span_diagnostic.handler().warn(msg)
190190
}
191-
fn span_note(&self, sp: span, msg: ~str) {
191+
fn span_note(@self, sp: span, msg: ~str) {
192192
self.span_diagnostic.span_note(sp, msg)
193193
}
194-
fn note(&self, msg: ~str) {
194+
fn note(@self, msg: ~str) {
195195
self.span_diagnostic.handler().note(msg)
196196
}
197-
fn span_bug(&self, sp: span, msg: ~str) -> ! {
197+
fn span_bug(@self, sp: span, msg: ~str) -> ! {
198198
self.span_diagnostic.span_bug(sp, msg)
199199
}
200-
fn bug(&self, msg: ~str) -> ! {
200+
fn bug(@self, msg: ~str) -> ! {
201201
self.span_diagnostic.handler().bug(msg)
202202
}
203-
fn span_unimpl(&self, sp: span, msg: ~str) -> ! {
203+
fn span_unimpl(@self, sp: span, msg: ~str) -> ! {
204204
self.span_diagnostic.span_unimpl(sp, msg)
205205
}
206-
fn unimpl(&self, msg: ~str) -> ! {
206+
fn unimpl(@self, msg: ~str) -> ! {
207207
self.span_diagnostic.handler().unimpl(msg)
208208
}
209-
fn span_lint_level(&self, level: lint::level, sp: span, +msg: ~str) {
209+
fn span_lint_level(@self, level: lint::level, sp: span, +msg: ~str) {
210210
match level {
211211
lint::allow => { },
212212
lint::warn => self.span_warn(sp, msg),
@@ -215,7 +215,7 @@ pub impl Session {
215215
}
216216
}
217217
}
218-
fn span_lint(&self, lint_mode: lint::lint,
218+
fn span_lint(@self, lint_mode: lint::lint,
219219
expr_id: ast::node_id,
220220
item_id: ast::node_id,
221221
span: span,
@@ -224,55 +224,55 @@ pub impl Session {
224224
self.lint_settings, lint_mode, expr_id, item_id);
225225
self.span_lint_level(level, span, msg);
226226
}
227-
fn next_node_id(&self) -> ast::node_id {
227+
fn next_node_id(@self) -> ast::node_id {
228228
return syntax::parse::next_node_id(self.parse_sess);
229229
}
230-
fn diagnostic(&self) -> @diagnostic::span_handler {
230+
fn diagnostic(@self) -> @diagnostic::span_handler {
231231
self.span_diagnostic
232232
}
233-
fn debugging_opt(&self, opt: uint) -> bool {
233+
fn debugging_opt(@self, opt: uint) -> bool {
234234
(self.opts.debugging_opts & opt) != 0u
235235
}
236236
// This exists to help with refactoring to eliminate impossible
237237
// cases later on
238-
fn impossible_case(&self, sp: span, msg: &str) -> ! {
238+
fn impossible_case(@self, sp: span, msg: &str) -> ! {
239239
self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
240240
}
241-
fn verbose(&self) -> bool { self.debugging_opt(verbose) }
242-
fn time_passes(&self) -> bool { self.debugging_opt(time_passes) }
243-
fn count_llvm_insns(&self) -> bool {
241+
fn verbose(@self) -> bool { self.debugging_opt(verbose) }
242+
fn time_passes(@self) -> bool { self.debugging_opt(time_passes) }
243+
fn count_llvm_insns(@self) -> bool {
244244
self.debugging_opt(count_llvm_insns)
245245
}
246-
fn count_type_sizes(&self) -> bool {
246+
fn count_type_sizes(@self) -> bool {
247247
self.debugging_opt(count_type_sizes)
248248
}
249-
fn time_llvm_passes(&self) -> bool {
249+
fn time_llvm_passes(@self) -> bool {
250250
self.debugging_opt(time_llvm_passes)
251251
}
252-
fn trans_stats(&self) -> bool { self.debugging_opt(trans_stats) }
253-
fn meta_stats(&self) -> bool { self.debugging_opt(meta_stats) }
254-
fn no_asm_comments(&self) -> bool { self.debugging_opt(no_asm_comments) }
255-
fn no_verify(&self) -> bool { self.debugging_opt(no_verify) }
256-
fn trace(&self) -> bool { self.debugging_opt(trace) }
257-
fn coherence(&self) -> bool { self.debugging_opt(coherence) }
258-
fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) }
259-
fn borrowck_note_pure(&self) -> bool {
252+
fn trans_stats(@self) -> bool { self.debugging_opt(trans_stats) }
253+
fn meta_stats(@self) -> bool { self.debugging_opt(meta_stats) }
254+
fn no_asm_comments(@self) -> bool { self.debugging_opt(no_asm_comments) }
255+
fn no_verify(@self) -> bool { self.debugging_opt(no_verify) }
256+
fn trace(@self) -> bool { self.debugging_opt(trace) }
257+
fn coherence(@self) -> bool { self.debugging_opt(coherence) }
258+
fn borrowck_stats(@self) -> bool { self.debugging_opt(borrowck_stats) }
259+
fn borrowck_note_pure(@self) -> bool {
260260
self.debugging_opt(borrowck_note_pure)
261261
}
262-
fn borrowck_note_loan(&self) -> bool {
262+
fn borrowck_note_loan(@self) -> bool {
263263
self.debugging_opt(borrowck_note_loan)
264264
}
265-
fn no_monomorphic_collapse(&self) -> bool {
265+
fn no_monomorphic_collapse(@self) -> bool {
266266
self.debugging_opt(no_monomorphic_collapse)
267267
}
268268

269-
fn str_of(&self, id: ast::ident) -> @~str {
269+
fn str_of(@self, id: ast::ident) -> @~str {
270270
self.parse_sess.interner.get(id)
271271
}
272-
fn ident_of(&self, +st: ~str) -> ast::ident {
272+
fn ident_of(@self, +st: ~str) -> ast::ident {
273273
self.parse_sess.interner.intern(@st)
274274
}
275-
fn intr(&self) -> @syntax::parse::token::ident_interner {
275+
fn intr(@self) -> @syntax::parse::token::ident_interner {
276276
self.parse_sess.interner
277277
}
278278
}

src/librustc/middle/liveness.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,8 @@ enum ReadKind {
16401640
PartiallyMovedValue
16411641
}
16421642

1643-
pub impl @Liveness {
1644-
fn check_ret(&self, id: node_id, sp: span, _fk: &visit::fn_kind,
1643+
pub impl Liveness {
1644+
fn check_ret(@self, id: node_id, sp: span, _fk: &visit::fn_kind,
16451645
entry_ln: LiveNode) {
16461646
if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() {
16471647
// if no_ret_var is live, then we fall off the end of the
@@ -1661,10 +1661,9 @@ pub impl @Liveness {
16611661
}
16621662
}
16631663
1664-
fn check_move_from_var(&self, ln: LiveNode,
1664+
fn check_move_from_var(@self, ln: LiveNode,
16651665
var: Variable,
1666-
move_expr: @expr)
1667-
{
1666+
move_expr: @expr) {
16681667
/*!
16691668
*
16701669
* Checks whether `var` is live on entry to any of the
@@ -1686,7 +1685,7 @@ pub impl @Liveness {
16861685
}
16871686
}
16881687
1689-
fn consider_last_use(&self, expr: @expr, ln: LiveNode, var: Variable) {
1688+
fn consider_last_use(@self, expr: @expr, ln: LiveNode, var: Variable) {
16901689
debug!("consider_last_use(expr.id=%?, ln=%s, var=%s)",
16911690
expr.id, ln.to_str(), var.to_str());
16921691
@@ -1696,7 +1695,7 @@ pub impl @Liveness {
16961695
}
16971696
}
16981697
1699-
fn check_lvalue(&self, expr: @expr, vt: vt<@Liveness>) {
1698+
fn check_lvalue(@self, expr: @expr, vt: vt<@Liveness>) {
17001699
match expr.node {
17011700
expr_path(_) => {
17021701
match self.tcx.def_map.get(&expr.id) {
@@ -1724,18 +1723,18 @@ pub impl @Liveness {
17241723
_ => {
17251724
// For other kinds of lvalues, no checks are required,
17261725
// and any embedded expressions are actually rvalues
1727-
visit::visit_expr(expr, *self, vt);
1726+
visit::visit_expr(expr, self, vt);
17281727
}
17291728
}
17301729
}
17311730
1732-
fn check_for_reassignments_in_pat(&self, pat: @pat) {
1731+
fn check_for_reassignments_in_pat(@self, pat: @pat) {
17331732
do self.pat_bindings(pat) |ln, var, sp| {
17341733
self.check_for_reassignment(ln, var, sp);
17351734
}
17361735
}
17371736
1738-
fn check_for_reassignment(&self, ln: LiveNode, var: Variable,
1737+
fn check_for_reassignment(@self, ln: LiveNode, var: Variable,
17391738
orig_span: span) {
17401739
match self.assigned_on_exit(ln, var) {
17411740
Some(ExprNode(span)) => {
@@ -1756,10 +1755,9 @@ pub impl @Liveness {
17561755
}
17571756
}
17581757
1759-
fn report_illegal_move(&self, lnk: LiveNodeKind,
1758+
fn report_illegal_move(@self, lnk: LiveNodeKind,
17601759
var: Variable,
1761-
move_expr: @expr)
1762-
{
1760+
move_expr: @expr) {
17631761
// the only time that it is possible to have a moved variable
17641762
// used by ExitNode would be arguments or fields in a ctor.
17651763
// we give a slightly different error message in those cases.
@@ -1822,11 +1820,10 @@ pub impl @Liveness {
18221820
};
18231821
}
18241822

1825-
fn report_move_location(&self, move_expr: @expr,
1823+
fn report_move_location(@self, move_expr: @expr,
18261824
var: Variable,
18271825
expr_descr: &str,
1828-
pronoun: &str)
1829-
{
1826+
pronoun: &str) {
18301827
let move_expr_ty = ty::expr_ty(self.tcx, move_expr);
18311828
let name = self.ir.variable_name(var);
18321829
self.tcx.sess.span_note(
@@ -1837,7 +1834,7 @@ pub impl @Liveness {
18371834
ty_to_str(self.tcx, move_expr_ty)));
18381835
}
18391836

1840-
fn report_illegal_read(&self, chk_span: span,
1837+
fn report_illegal_read(@self, chk_span: span,
18411838
lnk: LiveNodeKind,
18421839
var: Variable,
18431840
rk: ReadKind) {
@@ -1868,12 +1865,12 @@ pub impl @Liveness {
18681865
}
18691866
}
18701867

1871-
fn should_warn(&self, var: Variable) -> Option<@~str> {
1868+
fn should_warn(@self, var: Variable) -> Option<@~str> {
18721869
let name = self.ir.variable_name(var);
18731870
if name[0] == ('_' as u8) { None } else { Some(name) }
18741871
}
18751872

1876-
fn warn_about_unused_args(&self, decl: &fn_decl, entry_ln: LiveNode) {
1873+
fn warn_about_unused_args(@self, decl: &fn_decl, entry_ln: LiveNode) {
18771874
for decl.inputs.each |arg| {
18781875
do pat_util::pat_bindings(self.tcx.def_map, arg.pat)
18791876
|_bm, p_id, sp, _n| {
@@ -1883,15 +1880,15 @@ pub impl @Liveness {
18831880
}
18841881
}
18851882

1886-
fn warn_about_unused_or_dead_vars_in_pat(&self, pat: @pat) {
1883+
fn warn_about_unused_or_dead_vars_in_pat(@self, pat: @pat) {
18871884
do self.pat_bindings(pat) |ln, var, sp| {
18881885
if !self.warn_about_unused(sp, ln, var) {
18891886
self.warn_about_dead_assign(sp, ln, var);
18901887
}
18911888
}
18921889
}
18931890

1894-
fn warn_about_unused(&self, sp: span, ln: LiveNode, var: Variable)
1891+
fn warn_about_unused(@self, sp: span, ln: LiveNode, var: Variable)
18951892
-> bool {
18961893
if !self.used_on_entry(ln, var) {
18971894
for self.should_warn(var).each |name| {
@@ -1921,7 +1918,7 @@ pub impl @Liveness {
19211918
return false;
19221919
}
19231920

1924-
fn warn_about_dead_assign(&self, sp: span, ln: LiveNode, var: Variable) {
1921+
fn warn_about_dead_assign(@self, sp: span, ln: LiveNode, var: Variable) {
19251922
if self.live_on_exit(ln, var).is_none() {
19261923
for self.should_warn(var).each |name| {
19271924
// FIXME(#3266)--make liveness warnings lintable

src/librustc/middle/trans/common.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -677,28 +677,28 @@ pub fn block_parent(cx: block) -> block {
677677

678678
// Accessors
679679

680-
pub impl block {
681-
pure fn ccx(&self) -> @CrateContext { *self.fcx.ccx }
682-
pure fn tcx(&self) -> ty::ctxt { self.fcx.ccx.tcx }
683-
pure fn sess(&self) -> Session { self.fcx.ccx.sess }
680+
pub impl block_ {
681+
pure fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx }
682+
pure fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx }
683+
pure fn sess(@mut self) -> Session { self.fcx.ccx.sess }
684684

685-
fn node_id_to_str(&self, id: ast::node_id) -> ~str {
685+
fn node_id_to_str(@mut self, id: ast::node_id) -> ~str {
686686
ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
687687
}
688688

689-
fn expr_to_str(&self, e: @ast::expr) -> ~str {
689+
fn expr_to_str(@mut self, e: @ast::expr) -> ~str {
690690
expr_repr(self.tcx(), e)
691691
}
692692

693-
fn expr_is_lval(&self, e: @ast::expr) -> bool {
693+
fn expr_is_lval(@mut self, e: @ast::expr) -> bool {
694694
ty::expr_is_lval(self.tcx(), self.ccx().maps.method_map, e)
695695
}
696696

697-
fn expr_kind(&self, e: @ast::expr) -> ty::ExprKind {
697+
fn expr_kind(@mut self, e: @ast::expr) -> ty::ExprKind {
698698
ty::expr_kind(self.tcx(), self.ccx().maps.method_map, e)
699699
}
700700

701-
fn def(&self, nid: ast::node_id) -> ast::def {
701+
fn def(@mut self, nid: ast::node_id) -> ast::def {
702702
match self.tcx().def_map.find(&nid) {
703703
Some(v) => v,
704704
None => {
@@ -708,18 +708,18 @@ pub impl block {
708708
}
709709
}
710710

711-
fn val_str(&self, val: ValueRef) -> @str {
711+
fn val_str(@mut self, val: ValueRef) -> @str {
712712
val_str(self.ccx().tn, val)
713713
}
714714

715-
fn llty_str(&self, llty: TypeRef) -> @str {
715+
fn llty_str(@mut self, llty: TypeRef) -> @str {
716716
ty_str(self.ccx().tn, llty)
717717
}
718718

719-
fn ty_to_str(&self, t: ty::t) -> ~str {
719+
fn ty_to_str(@mut self, t: ty::t) -> ~str {
720720
ty_to_str(self.tcx(), t)
721721
}
722-
fn to_str(&self) -> ~str {
722+
fn to_str(@mut self) -> ~str {
723723
match self.node_info {
724724
Some(node_info) => {
725725
fmt!("[block %d]", node_info.id)

src/librustc/middle/typeck/coherence.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub fn get_base_type(inference_context: @mut InferCtxt,
7272
-> Option<t> {
7373
let resolved_type;
7474
match resolve_type(inference_context,
75-
original_type,
76-
resolve_ivar) {
75+
original_type,
76+
resolve_ivar) {
7777
Ok(resulting_type) if !type_is_ty_var(resulting_type) => {
7878
resolved_type = resulting_type;
7979
}
@@ -87,15 +87,6 @@ pub fn get_base_type(inference_context: @mut InferCtxt,
8787
}
8888

8989
match get(resolved_type).sty {
90-
ty_box(base_mutability_and_type) |
91-
ty_uniq(base_mutability_and_type) |
92-
ty_ptr(base_mutability_and_type) |
93-
ty_rptr(_, base_mutability_and_type) => {
94-
debug!("(getting base type) recurring");
95-
get_base_type(inference_context, span,
96-
base_mutability_and_type.ty)
97-
}
98-
9990
ty_enum(*) | ty_trait(*) | ty_struct(*) => {
10091
debug!("(getting base type) found base type");
10192
Some(resolved_type)
@@ -104,7 +95,8 @@ pub fn get_base_type(inference_context: @mut InferCtxt,
10495
ty_nil | ty_bot | ty_bool | ty_int(*) | ty_uint(*) | ty_float(*) |
10596
ty_estr(*) | ty_evec(*) | ty_bare_fn(*) | ty_closure(*) | ty_tup(*) |
10697
ty_infer(*) | ty_param(*) | ty_self | ty_type | ty_opaque_box |
107-
ty_opaque_closure_ptr(*) | ty_unboxed_vec(*) | ty_err => {
98+
ty_opaque_closure_ptr(*) | ty_unboxed_vec(*) | ty_err | ty_box(_) |
99+
ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => {
108100
debug!("(getting base type) no base type; found %?",
109101
get(original_type).sty);
110102
None

0 commit comments

Comments
 (0)