Skip to content

Commit e4c81fb

Browse files
committed
---
yaml --- r: 148198 b: refs/heads/try2 c: e19b1b1 h: refs/heads/master v: v3
1 parent 5d4d819 commit e4c81fb

File tree

10 files changed

+102
-23
lines changed

10 files changed

+102
-23
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: d578ecc4072a0e0fade7d564f0ae6dac31c3fb45
8+
refs/heads/try2: e19b1b129b266900f832a50f0ea50342471e414c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/docs.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ $(eval $(call libdoc,std,$(STDLIB_CRATE),$(CFG_BUILD)))
308308
$(eval $(call libdoc,extra,$(EXTRALIB_CRATE),$(CFG_BUILD)))
309309
$(eval $(call libdoc,native,$(LIBNATIVE_CRATE),$(CFG_BUILD)))
310310
$(eval $(call libdoc,green,$(LIBGREEN_CRATE),$(CFG_BUILD)))
311+
$(eval $(call libdoc,rustuv,$(LIBRUSTUV_CRATE),$(CFG_BUILD)))
311312

312313
$(eval $(call compiledoc,rustc,$(COMPILER_CRATE),$(CFG_BUILD)))
313314
$(eval $(call compiledoc,syntax,$(LIBSYNTAX_CRATE),$(CFG_BUILD)))

branches/try2/mk/install.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ uninstall:
194194
; \
195195
do rm -f $$i ; \
196196
done
197-
$(Q)rm -Rf $(PHL)/rustc
197+
$(Q)rm -Rf $(PHL)/$(CFG_RUSTLIBDIR)
198198
$(Q)rm -f $(CFG_MANDIR)/man1/rustc.1
199199
$(Q)rm -f $(CFG_MANDIR)/man1/rustdoc.1
200200
$(Q)rm -f $(CFG_MANDIR)/man1/rusti.1

branches/try2/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ use middle::moves;
2424
use middle::ty;
2525
use syntax::ast::{MutImmutable, MutMutable};
2626
use syntax::ast;
27+
use syntax::ast_map;
2728
use syntax::ast_util;
2829
use syntax::codemap::Span;
30+
use syntax::parse::token;
2931
use syntax::visit::Visitor;
3032
use syntax::visit;
3133
use util::ppaux::Repr;
@@ -77,6 +79,7 @@ pub fn check_loans(bccx: &BorrowckCtxt,
7779
clcx.visit_block(body, ());
7880
}
7981

82+
#[deriving(Eq)]
8083
enum MoveError {
8184
MoveOk,
8285
MoveWhileBorrowed(/*loan*/@LoanPath, /*loan*/Span)
@@ -125,6 +128,9 @@ impl<'a> CheckLoanCtxt<'a> {
125128
//! given `loan_path`
126129
127130
self.each_in_scope_loan(scope_id, |loan| {
131+
debug!("each_in_scope_restriction found loan: {:?}",
132+
loan.repr(self.tcx()));
133+
128134
let mut ret = true;
129135
for restr in loan.restrictions.iter() {
130136
if restr.loan_path == loan_path {
@@ -647,22 +653,34 @@ impl<'a> CheckLoanCtxt<'a> {
647653

648654
pub fn analyze_move_out_from(&self,
649655
expr_id: ast::NodeId,
650-
move_path: @LoanPath) -> MoveError {
656+
mut move_path: @LoanPath)
657+
-> MoveError {
651658
debug!("analyze_move_out_from(expr_id={:?}, move_path={})",
652-
expr_id, move_path.repr(self.tcx()));
653-
654-
// FIXME(#4384) inadequare if/when we permit `move a.b`
655-
656-
let mut ret = MoveOk;
659+
ast_map::node_id_to_str(self.tcx().items,
660+
expr_id,
661+
token::get_ident_interner()),
662+
move_path.repr(self.tcx()));
663+
664+
// We must check every element of a move path. See
665+
// `borrowck-move-subcomponent.rs` for a test case.
666+
loop {
667+
// check for a conflicting loan:
668+
let mut ret = MoveOk;
669+
self.each_in_scope_restriction(expr_id, move_path, |loan, _| {
670+
// Any restriction prevents moves.
671+
ret = MoveWhileBorrowed(loan.loan_path, loan.span);
672+
false
673+
});
657674

658-
// check for a conflicting loan:
659-
self.each_in_scope_restriction(expr_id, move_path, |loan, _| {
660-
// Any restriction prevents moves.
661-
ret = MoveWhileBorrowed(loan.loan_path, loan.span);
662-
false
663-
});
675+
if ret != MoveOk {
676+
return ret
677+
}
664678

665-
ret
679+
match *move_path {
680+
LpVar(_) => return MoveOk,
681+
LpExtend(subpath, _, _) => move_path = subpath,
682+
}
683+
}
666684
}
667685

668686
pub fn check_call(&self,

branches/try2/src/librustc/middle/borrowck/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,10 @@ impl Repr for LoanPath {
872872
fn repr(&self, tcx: ty::ctxt) -> ~str {
873873
match self {
874874
&LpVar(id) => {
875-
format!("$({:?})", id)
875+
format!("$({})",
876+
ast_map::node_id_to_str(tcx.items,
877+
id,
878+
token::get_ident_interner()))
876879
}
877880

878881
&LpExtend(lp, _, LpDeref(_)) => {

branches/try2/src/librustdoc/html/render.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub struct Cache {
157157
priv stack: ~[~str],
158158
priv parent_stack: ~[ast::NodeId],
159159
priv search_index: ~[IndexItem],
160+
priv privmod: bool,
160161
}
161162

162163
/// Helper struct to render all source code to HTML pages
@@ -241,6 +242,7 @@ pub fn run(mut crate: clean::Crate, dst: Path) {
241242
parent_stack: ~[],
242243
search_index: ~[],
243244
extern_locations: HashMap::new(),
245+
privmod: false,
244246
};
245247
cache.stack.push(crate.name.clone());
246248
crate = cache.fold_crate(crate);
@@ -455,6 +457,16 @@ impl<'a> SourceCollector<'a> {
455457

456458
impl DocFolder for Cache {
457459
fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
460+
// If this is a private module, we don't want it in the search index.
461+
let orig_privmod = match item.inner {
462+
clean::ModuleItem(..) => {
463+
let prev = self.privmod;
464+
self.privmod = prev || item.visibility != Some(ast::Public);
465+
prev
466+
}
467+
_ => self.privmod,
468+
};
469+
458470
// Register any generics to their corresponding string. This is used
459471
// when pretty-printing types
460472
match item.inner {
@@ -530,7 +542,7 @@ impl DocFolder for Cache {
530542
_ => Some((None, self.stack.as_slice()))
531543
};
532544
match parent {
533-
Some((parent, path)) => {
545+
Some((parent, path)) if !self.privmod => {
534546
self.search_index.push(IndexItem {
535547
ty: shortty(&item),
536548
name: s.to_owned(),
@@ -539,7 +551,7 @@ impl DocFolder for Cache {
539551
parent: parent,
540552
});
541553
}
542-
None => {}
554+
Some(..) | None => {}
543555
}
544556
}
545557
None => {}
@@ -612,8 +624,12 @@ impl DocFolder for Cache {
612624
// Private modules may survive the strip-private pass if
613625
// they contain impls for public types, but those will get
614626
// stripped here
615-
clean::Item { inner: clean::ModuleItem(ref m), .. }
616-
if m.items.len() == 0 => None,
627+
clean::Item { inner: clean::ModuleItem(ref m),
628+
visibility, .. }
629+
if (m.items.len() == 0 &&
630+
item.doc_value().is_none()) ||
631+
visibility != Some(ast::Public) => None,
632+
617633
i => Some(i),
618634
}
619635
}
@@ -622,6 +638,7 @@ impl DocFolder for Cache {
622638

623639
if pushed { self.stack.pop(); }
624640
if parent_pushed { self.parent_stack.pop(); }
641+
self.privmod = orig_privmod;
625642
return ret;
626643
}
627644
}
@@ -1186,7 +1203,7 @@ fn item_struct(w: &mut Writer, it: &clean::Item, s: &clean::Struct) {
11861203

11871204
document(w, it);
11881205
match s.struct_type {
1189-
doctree::Plain => {
1206+
doctree::Plain if s.fields.len() > 0 => {
11901207
write!(w, "<h2 class='fields'>Fields</h2>\n<table>");
11911208
for field in s.fields.iter() {
11921209
write!(w, "<tr><td id='structfield.{name}'>\

branches/try2/src/librustdoc/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub fn opts() -> ~[groups::OptGroup] {
8383
use extra::getopts::groups::*;
8484
~[
8585
optflag("h", "help", "show this help message"),
86+
optflag("", "version", "print rustdoc's version"),
8687
optopt("r", "input-format", "the input type of the specified file",
8788
"[rust|json]"),
8889
optopt("w", "output-format", "the output type to write",
@@ -119,6 +120,9 @@ pub fn main_args(args: &[~str]) -> int {
119120
if matches.opt_present("h") || matches.opt_present("help") {
120121
usage(args[0]);
121122
return 0;
123+
} else if matches.opt_present("version") {
124+
rustc::version(args[0]);
125+
return 0;
122126
}
123127

124128
if matches.free.len() == 0 {

branches/try2/src/librustdoc/passes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ impl<'a> fold::DocFolder for Stripper<'a> {
136136
Some(i) => {
137137
match i.inner {
138138
// emptied modules/impls have no need to exist
139-
clean::ModuleItem(ref m) if m.items.len() == 0 => None,
139+
clean::ModuleItem(ref m)
140+
if m.items.len() == 0 &&
141+
i.doc_value().is_none() => None,
140142
clean::ImplItem(ref i) if i.methods.len() == 0 => None,
141143
_ => {
142144
self.retained.insert(i.id);

branches/try2/src/librustpkg/parse_args.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ pub struct ParseResult {
3636
/// Parses command line arguments of rustpkg.
3737
/// Returns a triplet (command, remaining_args, context)
3838
pub fn parse_args(args: &[~str]) -> Result<ParseResult, int> {
39-
let opts = ~[ getopts::optflag("no-link"),
39+
let opts = ~[ getopts::optflag("h"), getopts::optflag("help"),
40+
getopts::optflag("no-link"),
4041
getopts::optflag("no-trans"),
4142
// n.b. Ignores different --pretty options for now
4243
getopts::optflag("pretty"),
@@ -71,6 +72,12 @@ pub fn parse_args(args: &[~str]) -> Result<ParseResult, int> {
7172
let pretty = matches.opt_present("pretty");
7273
let emit_llvm = matches.opt_present("emit-llvm");
7374

75+
if matches.opt_present("h") ||
76+
matches.opt_present("help") {
77+
usage::general();
78+
return Err(0);
79+
}
80+
7481
if matches.opt_present("v") ||
7582
matches.opt_present("version") {
7683
version(args[0]);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Tests that the borrow checker checks all components of a path when moving
12+
// out.
13+
14+
#[no_std];
15+
16+
struct S {
17+
x : ~int
18+
}
19+
20+
fn f<T>(_: T) {}
21+
22+
fn main() {
23+
let a : S = S { x : ~1 };
24+
let pb = &a;
25+
let S { x: ax } = a; //~ ERROR cannot move out
26+
f(pb);
27+
}

0 commit comments

Comments
 (0)