Skip to content

Commit 3db85a1

Browse files
committed
---
yaml --- r: 151101 b: refs/heads/try2 c: 7266587 h: refs/heads/master i: 151099: 88633ea v: v3
1 parent d13d23d commit 3db85a1

Some content is hidden

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

59 files changed

+470
-410
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 7d70434a1e0ba68753b7d1e83f594dea6d23dd51
8+
refs/heads/try2: 7266587f3e52513328926d9229be7003323ceac8
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/compiletest/compiletest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,7 @@ pub fn test_opts(config: &config) -> test::TestOpts {
267267
ratchet_metrics: config.ratchet_metrics.clone(),
268268
ratchet_noise_percent: config.ratchet_noise_percent.clone(),
269269
save_metrics: config.save_metrics.clone(),
270-
test_shard: config.test_shard.clone(),
271-
nocapture: false,
270+
test_shard: config.test_shard.clone()
272271
}
273272
}
274273

branches/try2/src/compiletest/runtest.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ fn fatal(err: ~str) -> ! { error(err); fail!(); }
955955
fn fatal_ProcRes(err: ~str, proc_res: &ProcRes) -> ! {
956956
print!("\n\
957957
error: {}\n\
958-
status: {}\n\
959958
command: {}\n\
960959
stdout:\n\
961960
------------------------------------------\n\
@@ -966,8 +965,7 @@ stderr:\n\
966965
{}\n\
967966
------------------------------------------\n\
968967
\n",
969-
err, proc_res.status, proc_res.cmdline, proc_res.stdout,
970-
proc_res.stderr);
968+
err, proc_res.cmdline, proc_res.stdout, proc_res.stderr);
971969
fail!();
972970
}
973971

branches/try2/src/etc/vim/indent/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function GetRustIndent(lnum)
105105
if prevline[len(prevline) - 1] == ","
106106
\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
107107
\ && prevline !~ "^\\s*fn\\s"
108-
\ && prevline !~ "\\([^\\(\\)]\+,$"
108+
\ && prevline !~ "([^()]\\+,$"
109109
" Oh ho! The previous line ended in a comma! I bet cindent will try to
110110
" take this too far... For now, let's normally use the previous line's
111111
" indent.

branches/try2/src/libfourcc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) ->
9191

9292
let s = match expr.node {
9393
// expression is a literal
94-
ast::ExprLit(ref lit) => match lit.node {
94+
ast::ExprLit(lit) => match lit.node {
9595
// string literal
9696
ast::LitStr(ref s, _) => {
9797
if s.get().char_len() != 4 {

branches/try2/src/librustc/driver/driver.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ pub fn phase_3_run_analysis_passes(sess: Session,
346346
time(time_passes, "effect checking", (), |_|
347347
middle::effect::check_crate(&ty_cx, krate));
348348

349-
let middle::moves::MoveMaps {moves_map, capture_map} =
349+
let middle::moves::MoveMaps {moves_map, moved_variables_set,
350+
capture_map} =
350351
time(time_passes, "compute moves", (), |_|
351352
middle::moves::compute_moves(&ty_cx, krate));
352353

@@ -356,11 +357,14 @@ pub fn phase_3_run_analysis_passes(sess: Session,
356357
time(time_passes, "liveness checking", (), |_|
357358
middle::liveness::check_crate(&ty_cx, &capture_map, krate));
358359

359-
time(time_passes, "borrow checking", (), |_|
360-
middle::borrowck::check_crate(&ty_cx, &moves_map,
361-
&capture_map, krate));
360+
let root_map =
361+
time(time_passes, "borrow checking", (), |_|
362+
middle::borrowck::check_crate(&ty_cx, &moves_map,
363+
&moved_variables_set,
364+
&capture_map, krate));
362365

363366
drop(moves_map);
367+
drop(moved_variables_set);
364368

365369
time(time_passes, "kind checking", (), |_|
366370
kind::check_crate(&ty_cx, krate));
@@ -385,6 +389,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
385389
exported_items: exported_items,
386390
public_items: public_items,
387391
maps: astencode::Maps {
392+
root_map: root_map,
388393
capture_map: RefCell::new(capture_map)
389394
},
390395
reachable: reachable_map

branches/try2/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ use writer = serialize::ebml::writer;
5454

5555
// Auxiliary maps of things to be encoded
5656
pub struct Maps {
57+
pub root_map: middle::borrowck::root_map,
5758
pub capture_map: RefCell<middle::moves::CaptureMap>,
5859
}
5960

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

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ struct GuaranteeLifetimeContext<'a> {
6565
}
6666

6767
impl<'a> GuaranteeLifetimeContext<'a> {
68+
fn tcx(&self) -> &'a ty::ctxt {
69+
self.bccx.tcx
70+
}
6871

6972
fn check(&self, cmt: &mc::cmt, discr_scope: Option<ast::NodeId>) -> R {
7073
//! Main routine. Walks down `cmt` until we find the "guarantor".
@@ -87,10 +90,29 @@ impl<'a> GuaranteeLifetimeContext<'a> {
8790
Ok(())
8891
}
8992

93+
mc::cat_deref(ref base, derefs, mc::GcPtr) => {
94+
let base_scope = self.scope(base);
95+
96+
// L-Deref-Managed-Imm-User-Root
97+
let omit_root =
98+
self.bccx.is_subregion_of(self.loan_region, base_scope) &&
99+
self.is_rvalue_or_immutable(base) &&
100+
!self.is_moved(base);
101+
102+
if !omit_root {
103+
// L-Deref-Managed-Imm-Compiler-Root
104+
// L-Deref-Managed-Mut-Compiler-Root
105+
self.check_root(cmt, base, derefs, discr_scope)
106+
} else {
107+
debug!("omitting root, base={}, base_scope={:?}",
108+
base.repr(self.tcx()), base_scope);
109+
Ok(())
110+
}
111+
}
112+
90113
mc::cat_downcast(ref base) |
91114
mc::cat_deref(ref base, _, mc::OwnedPtr) | // L-Deref-Send
92-
mc::cat_interior(ref base, _) | // L-Field
93-
mc::cat_deref(ref base, _, mc::GcPtr) => {
115+
mc::cat_interior(ref base, _) => { // L-Field
94116
self.check(base, discr_scope)
95117
}
96118

@@ -152,6 +174,74 @@ impl<'a> GuaranteeLifetimeContext<'a> {
152174
}
153175
}
154176

177+
fn is_rvalue_or_immutable(&self,
178+
cmt: &mc::cmt) -> bool {
179+
//! We can omit the root on an `@T` value if the location
180+
//! that holds the box is either (1) an rvalue, in which case
181+
//! it is in a non-user-accessible temporary, or (2) an immutable
182+
//! lvalue.
183+
184+
cmt.mutbl.is_immutable() || match cmt.guarantor().cat {
185+
mc::cat_rvalue(..) => true,
186+
_ => false
187+
}
188+
}
189+
190+
fn check_root(&self,
191+
cmt_deref: &mc::cmt,
192+
cmt_base: &mc::cmt,
193+
derefs: uint,
194+
discr_scope: Option<ast::NodeId>) -> R {
195+
debug!("check_root(cmt_deref={}, cmt_base={}, derefs={:?}, \
196+
discr_scope={:?})",
197+
cmt_deref.repr(self.tcx()),
198+
cmt_base.repr(self.tcx()),
199+
derefs,
200+
discr_scope);
201+
202+
// Make sure that the loan does not exceed the maximum time
203+
// that we can root the value, dynamically.
204+
let root_region = ty::ReScope(self.root_scope_id);
205+
if !self.bccx.is_subregion_of(self.loan_region, root_region) {
206+
return Err(self.report_error(
207+
err_out_of_root_scope(root_region, self.loan_region)));
208+
}
209+
210+
// Extract the scope id that indicates how long the rooting is required
211+
let root_scope = match self.loan_region {
212+
ty::ReScope(id) => id,
213+
_ => {
214+
// the check above should fail for anything is not ReScope
215+
self.bccx.tcx.sess.span_bug(
216+
cmt_base.span,
217+
format!("cannot issue root for scope region: {:?}",
218+
self.loan_region));
219+
}
220+
};
221+
222+
// If inside of a match arm, expand the rooting to the entire
223+
// match. See the detailed discussion in `check()` above.
224+
let root_scope = match discr_scope {
225+
None => root_scope,
226+
Some(id) => {
227+
if self.bccx.is_subscope_of(root_scope, id) {
228+
id
229+
} else {
230+
root_scope
231+
}
232+
}
233+
};
234+
235+
// Add a record of what is required
236+
let rm_key = root_map_key {id: cmt_deref.id, derefs: derefs};
237+
let root_info = RootInfo {scope: root_scope};
238+
239+
self.bccx.root_map.borrow_mut().insert(rm_key, root_info);
240+
241+
debug!("root_key: {:?} root_info: {:?}", rm_key, root_info);
242+
Ok(())
243+
}
244+
155245
fn check_scope(&self, max_scope: ty::Region) -> R {
156246
//! Reports an error if `loan_region` is larger than `valid_scope`
157247
@@ -162,6 +252,32 @@ impl<'a> GuaranteeLifetimeContext<'a> {
162252
}
163253
}
164254

255+
fn is_moved(&self, cmt: &mc::cmt) -> bool {
256+
//! True if `cmt` is something that is potentially moved
257+
//! out of the current stack frame.
258+
259+
match cmt.guarantor().cat {
260+
mc::cat_local(id) |
261+
mc::cat_arg(id) => {
262+
self.bccx.moved_variables_set.contains(&id)
263+
}
264+
mc::cat_rvalue(..) |
265+
mc::cat_static_item |
266+
mc::cat_copied_upvar(..) |
267+
mc::cat_deref(..) |
268+
mc::cat_upvar(..) => {
269+
false
270+
}
271+
ref r @ mc::cat_downcast(..) |
272+
ref r @ mc::cat_interior(..) |
273+
ref r @ mc::cat_discr(..) => {
274+
self.tcx().sess.span_bug(
275+
cmt.span,
276+
format!("illegal guarantor category: {:?}", r));
277+
}
278+
}
279+
}
280+
165281
fn scope(&self, cmt: &mc::cmt) -> ty::Region {
166282
//! Returns the maximal region scope for the which the
167283
//! lvalue `cmt` is guaranteed to be valid without any

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

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

104-
mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) |
105-
mc::cat_deref(cmt_base, _, pk @ mc::GcPtr) => {
104+
mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) => {
106105
// R-Deref-Send-Pointer
107106
//
108107
// When we borrow the interior of an owned pointer, we
109108
// cannot permit the base to be mutated, because that
110109
// would cause the unique pointer to be freed.
111-
//
112-
// For a managed pointer, the rules are basically the
113-
// same, because this could be the last ref.
114-
// Eventually we should make these non-special and
115-
// just rely on Deref<T> implementation.
116110
let result = self.restrict(
117111
cmt_base,
118112
restrictions | RESTR_MUTATE);
@@ -140,6 +134,11 @@ impl<'a> RestrictionsContext<'a> {
140134
Safe
141135
}
142136

137+
mc::cat_deref(_, _, mc::GcPtr) => {
138+
// R-Deref-Imm-Managed
139+
Safe
140+
}
141+
143142
mc::cat_deref(cmt_base, _, pk @ mc::BorrowedPtr(ty::MutBorrow, lt)) => {
144143
// R-Deref-Mut-Borrowed
145144
if !self.bccx.is_subregion_of(self.loan_region, lt) {

0 commit comments

Comments
 (0)