Skip to content

Commit b285f1e

Browse files
committed
auto merge of #8455 : nikomatsakis/rust/issue-5762-objects-dralston-d, r=graydon
Fix #5762 and various other aspects of object invocation. r? @graydon
2 parents 63c62be + 7343478 commit b285f1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1155
-560
lines changed

src/librustc/back/abi.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ pub static tydesc_field_take_glue: uint = 2u;
4646
pub static tydesc_field_drop_glue: uint = 3u;
4747
pub static tydesc_field_free_glue: uint = 4u;
4848
pub static tydesc_field_visit_glue: uint = 5u;
49-
pub static n_tydesc_fields: uint = 6u;
49+
pub static tydesc_field_borrow_offset: uint = 6u;
50+
pub static n_tydesc_fields: uint = 7u;
5051

5152
// The two halves of a closure: code and environment.
5253
pub static fn_field_code: uint = 0u;

src/librustc/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ pub fn build_session(sopts: @session::options,
785785
pub fn build_session_(sopts: @session::options,
786786
cm: @codemap::CodeMap,
787787
demitter: diagnostic::Emitter,
788-
span_diagnostic_handler: @diagnostic::span_handler)
788+
span_diagnostic_handler: @mut diagnostic::span_handler)
789789
-> Session {
790790
let target_cfg = build_target_config(sopts, demitter);
791791
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,

src/librustc/driver/session.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub struct Session_ {
192192
// For a library crate, this is always none
193193
entry_fn: @mut Option<(NodeId, codemap::span)>,
194194
entry_type: @mut Option<EntryFnType>,
195-
span_diagnostic: @diagnostic::span_handler,
195+
span_diagnostic: @mut diagnostic::span_handler,
196196
filesearch: @filesearch::FileSearch,
197197
building_library: @mut bool,
198198
working_dir: Path,
@@ -261,7 +261,7 @@ impl Session_ {
261261
pub fn next_node_id(@self) -> ast::NodeId {
262262
return syntax::parse::next_node_id(self.parse_sess);
263263
}
264-
pub fn diagnostic(@self) -> @diagnostic::span_handler {
264+
pub fn diagnostic(@self) -> @mut diagnostic::span_handler {
265265
self.span_diagnostic
266266
}
267267
pub fn debugging_opt(@self, opt: uint) -> bool {

src/librustc/metadata/creader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use syntax::oldvisit;
2929

3030
// Traverses an AST, reading all the information about use'd crates and extern
3131
// libraries necessary for later resolving, typechecking, linking, etc.
32-
pub fn read_crates(diag: @span_handler,
32+
pub fn read_crates(diag: @mut span_handler,
3333
crate: &ast::Crate,
3434
cstore: @mut cstore::CStore,
3535
filesearch: @FileSearch,
@@ -74,7 +74,7 @@ fn dump_crates(crate_cache: &[cache_entry]) {
7474
}
7575

7676
fn warn_if_multiple_versions(e: @mut Env,
77-
diag: @span_handler,
77+
diag: @mut span_handler,
7878
crate_cache: &[cache_entry]) {
7979
use std::either::*;
8080

@@ -113,7 +113,7 @@ fn warn_if_multiple_versions(e: @mut Env,
113113
}
114114

115115
struct Env {
116-
diag: @span_handler,
116+
diag: @mut span_handler,
117117
filesearch: @FileSearch,
118118
cstore: @mut cstore::CStore,
119119
os: loader::os,

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub type encode_inlined_item<'self> = &'self fn(ecx: &EncodeContext,
5555
ii: ast::inlined_item);
5656

5757
pub struct EncodeParams<'self> {
58-
diag: @span_handler,
58+
diag: @mut span_handler,
5959
tcx: ty::ctxt,
6060
reexports2: middle::resolve::ExportMap2,
6161
item_symbols: &'self HashMap<ast::NodeId, ~str>,
@@ -82,7 +82,7 @@ struct Stats {
8282
}
8383

8484
pub struct EncodeContext<'self> {
85-
diag: @span_handler,
85+
diag: @mut span_handler,
8686
tcx: ty::ctxt,
8787
stats: @mut Stats,
8888
reexports2: middle::resolve::ExportMap2,

src/librustc/metadata/loader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub enum os {
4343
}
4444

4545
pub struct Context {
46-
diag: @span_handler,
46+
diag: @mut span_handler,
4747
filesearch: @FileSearch,
4848
span: span,
4949
ident: @str,
@@ -163,7 +163,7 @@ pub fn package_id_from_metas(metas: &[@ast::MetaItem]) -> Option<@str> {
163163
}
164164

165165
pub fn note_linkage_attrs(intr: @ident_interner,
166-
diag: @span_handler,
166+
diag: @mut span_handler,
167167
attrs: ~[ast::Attribute]) {
168168
let r = attr::find_linkage_metas(attrs);
169169
for mi in r.iter() {

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use syntax::diagnostic::span_handler;
2525
use syntax::print::pprust::*;
2626

2727
pub struct ctxt {
28-
diag: @span_handler,
28+
diag: @mut span_handler,
2929
// Def -> str Callback:
3030
ds: @fn(def_id) -> ~str,
3131
// The type context.

src/librustc/middle/astencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,8 @@ impl tr for method_origin {
586586
}
587587
)
588588
}
589-
typeck::method_trait(did, m, vstore) => {
590-
typeck::method_trait(did.tr(xcx), m, vstore)
589+
typeck::method_trait(did, m) => {
590+
typeck::method_trait(did.tr(xcx), m)
591591
}
592592
}
593593
}

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ impl<'self> CheckLoanCtxt<'self> {
362362
}
363363

364364
mc::cat_discr(b, _) |
365-
mc::cat_deref(b, _, mc::uniq_ptr(*)) => {
365+
mc::cat_deref(b, _, mc::uniq_ptr) => {
366366
assert_eq!(cmt.mutbl, mc::McInherited);
367367
cmt = b;
368368
}

src/librustc/middle/borrowck/gather_loans/gather_moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn check_is_legal_to_move_from(bccx: @BorrowckCtxt,
173173
}
174174
}
175175

176-
mc::cat_deref(b, _, mc::uniq_ptr(*)) |
176+
mc::cat_deref(b, _, mc::uniq_ptr) |
177177
mc::cat_discr(b, _) => {
178178
check_is_legal_to_move_from(bccx, cmt0, b)
179179
}

src/librustc/middle/borrowck/gather_loans/lifetime.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl GuaranteeLifetimeContext {
7474
mc::cat_arg(*) | // L-Local
7575
mc::cat_self(*) | // L-Local
7676
mc::cat_deref(_, _, mc::region_ptr(*)) | // L-Deref-Borrowed
77-
mc::cat_deref(_, _, mc::unsafe_ptr) => {
77+
mc::cat_deref(_, _, mc::unsafe_ptr(*)) => {
7878
let scope = self.scope(cmt);
7979
self.check_scope(scope)
8080
}
@@ -108,7 +108,7 @@ impl GuaranteeLifetimeContext {
108108
}
109109

110110
mc::cat_downcast(base) |
111-
mc::cat_deref(base, _, mc::uniq_ptr(*)) | // L-Deref-Send
111+
mc::cat_deref(base, _, mc::uniq_ptr) | // L-Deref-Send
112112
mc::cat_interior(base, _) => { // L-Field
113113
self.check(base, discr_scope)
114114
}
@@ -347,7 +347,7 @@ impl GuaranteeLifetimeContext {
347347
r
348348
}
349349
mc::cat_downcast(cmt) |
350-
mc::cat_deref(cmt, _, mc::uniq_ptr(*)) |
350+
mc::cat_deref(cmt, _, mc::uniq_ptr) |
351351
mc::cat_deref(cmt, _, mc::gc_ptr(*)) |
352352
mc::cat_interior(cmt, _) |
353353
mc::cat_stack_upvar(cmt) |

src/librustc/middle/borrowck/gather_loans/mod.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,21 @@ impl GatherLoanCtxt {
352352
r)
353353
}
354354
ty::AutoBorrowFn(r) => {
355-
let cmt_deref = mcx.cat_deref_fn(expr, cmt, 0);
355+
let cmt_deref = mcx.cat_deref_fn_or_obj(expr, cmt, 0);
356356
self.guarantee_valid(expr.id,
357357
expr.span,
358358
cmt_deref,
359359
m_imm,
360360
r)
361361
}
362+
ty::AutoBorrowObj(r, m) => {
363+
let cmt_deref = mcx.cat_deref_fn_or_obj(expr, cmt, 0);
364+
self.guarantee_valid(expr.id,
365+
expr.span,
366+
cmt_deref,
367+
m,
368+
r)
369+
}
362370
ty::AutoUnsafe(_) => {}
363371
}
364372
}

src/librustc/middle/borrowck/gather_loans/restrictions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl RestrictionsContext {
101101
self.extend(result, cmt.mutbl, LpInterior(i), restrictions)
102102
}
103103

104-
mc::cat_deref(cmt_base, _, mc::uniq_ptr(*)) => {
104+
mc::cat_deref(cmt_base, _, mc::uniq_ptr) => {
105105
// R-Deref-Send-Pointer
106106
//
107107
// When we borrow the interior of an owned pointer, we
@@ -194,7 +194,7 @@ impl RestrictionsContext {
194194
}
195195
}
196196

197-
mc::cat_deref(_, _, mc::unsafe_ptr) => {
197+
mc::cat_deref(_, _, mc::unsafe_ptr(*)) => {
198198
// We are very trusting when working with unsafe pointers.
199199
Safe
200200
}

src/librustc/middle/lint.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ enum AnyVisitor {
301301
// recursive call can use the original visitor's method, although the
302302
// recursing visitor supplied to the method is the item stopping visitor.
303303
OldVisitor(oldvisit::vt<@mut Context>, oldvisit::vt<@mut Context>),
304-
NewVisitor(@visit::Visitor<()>),
304+
NewVisitor(@mut visit::Visitor<()>),
305305
}
306306

307307
struct Context {
@@ -465,7 +465,7 @@ impl Context {
465465
self.visitors.push(OldVisitor(v, item_stopping_visitor(v)));
466466
}
467467

468-
fn add_lint(&mut self, v: @visit::Visitor<()>) {
468+
fn add_lint(&mut self, v: @mut visit::Visitor<()>) {
469469
self.visitors.push(NewVisitor(v));
470470
}
471471

@@ -989,7 +989,7 @@ fn lint_unused_mut() -> oldvisit::vt<@mut Context> {
989989
})
990990
}
991991

992-
fn lint_session(cx: @mut Context) -> @visit::Visitor<()> {
992+
fn lint_session(cx: @mut Context) -> @mut visit::Visitor<()> {
993993
ast_util::id_visitor(|id| {
994994
match cx.tcx.sess.lints.pop(&id) {
995995
None => {},

0 commit comments

Comments
 (0)