Skip to content

Commit 33b0c52

Browse files
committed
---
yaml --- r: 130715 b: refs/heads/master c: 742f49c h: refs/heads/master i: 130713: 04d045c 130711: 76fceb8 v: v3
1 parent c7fa222 commit 33b0c52

File tree

24 files changed

+149
-67
lines changed

24 files changed

+149
-67
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: aaf141d399097d0ea84288b9ad1dc842a6158a5c
2+
refs/heads/master: 742f49c961426be422c479c7e47957c45e560ba6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6faa4f33a42de32579e02a8d030db920d360e2b5
55
refs/heads/try: a2473a89da106f7dd3be86e9d52fe23f43d5bfa5

trunk/src/libnative/io/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ pub fn read<T>(fd: sock_t,
959959
// wait for the socket to become readable again.
960960
let _guard = lock();
961961
match retry(|| read(deadline.is_some())) {
962-
-1 if util::wouldblock() => {}
962+
-1 if util::wouldblock() => { assert!(deadline.is_some()); }
963963
-1 => return Err(os::last_error()),
964964
n => { ret = n; break }
965965
}

trunk/src/librustc/back/link.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use util::ppaux;
2828
use util::sha2::{Digest, Sha256};
2929

3030
use std::char;
31+
use std::collections::HashSet;
3132
use std::io::{fs, TempDir, Command};
3233
use std::io;
3334
use std::mem;
@@ -569,7 +570,10 @@ fn link_binary_output(sess: &Session,
569570
fn archive_search_paths(sess: &Session) -> Vec<Path> {
570571
let mut rustpath = filesearch::rust_path();
571572
rustpath.push(sess.target_filesearch().get_lib_path());
572-
let mut search: Vec<Path> = sess.opts.addl_lib_search_paths.borrow().clone();
573+
// FIXME: Addl lib search paths are an unordered HashSet?
574+
// Shouldn't this search be done in some order?
575+
let addl_lib_paths: HashSet<Path> = sess.opts.addl_lib_search_paths.borrow().clone();
576+
let mut search: Vec<Path> = addl_lib_paths.move_iter().collect();
573577
search.push_all(rustpath.as_slice());
574578
return search;
575579
}

trunk/src/librustc/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,6 @@ register_diagnostics!(
169169
E0157,
170170
E0158,
171171
E0159,
172-
E0160
172+
E0160,
173+
E0161
173174
)

trunk/src/librustc/driver/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use syntax::diagnostic::{ColorConfig, Auto, Always, Never};
3030
use syntax::parse;
3131
use syntax::parse::token::InternedString;
3232

33-
use std::collections::HashMap;
33+
use std::collections::{HashSet, HashMap};
3434
use getopts::{optopt, optmulti, optflag, optflagopt};
3535
use getopts;
3636
use std::cell::{RefCell};
@@ -76,7 +76,7 @@ pub struct Options {
7676
// This was mutable for rustpkg, which updates search paths based on the
7777
// parsed code. It remains mutable in case its replacements wants to use
7878
// this.
79-
pub addl_lib_search_paths: RefCell<Vec<Path>>,
79+
pub addl_lib_search_paths: RefCell<HashSet<Path>>,
8080
pub maybe_sysroot: Option<Path>,
8181
pub target_triple: String,
8282
// User-specified cfg meta items. The compiler itself will add additional
@@ -113,7 +113,7 @@ pub fn basic_options() -> Options {
113113
lint_opts: Vec::new(),
114114
describe_lints: false,
115115
output_types: Vec::new(),
116-
addl_lib_search_paths: RefCell::new(Vec::new()),
116+
addl_lib_search_paths: RefCell::new(HashSet::new()),
117117
maybe_sysroot: None,
118118
target_triple: driver::host_triple().to_string(),
119119
cfg: Vec::new(),

trunk/src/librustc/driver/driver.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
404404
time(time_passes, "borrow checking", (), |_|
405405
middle::borrowck::check_crate(&ty_cx, krate));
406406

407+
time(time_passes, "rvalue checking", (), |_|
408+
middle::check_rvalues::check_crate(&ty_cx, krate));
409+
407410
time(time_passes, "kind checking", (), |_|
408411
kind::check_crate(&ty_cx, krate));
409412

trunk/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub mod middle {
8080
pub mod check_const;
8181
pub mod check_loop;
8282
pub mod check_match;
83+
pub mod check_rvalues;
8384
pub mod check_static;
8485
pub mod const_eval;
8586
pub mod dataflow;

trunk/src/librustc/metadata/filesearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub type pick<'a> = |path: &Path|: 'a -> FileMatch;
3030

3131
pub struct FileSearch<'a> {
3232
pub sysroot: &'a Path,
33-
pub addl_lib_search_paths: &'a RefCell<Vec<Path>>,
33+
pub addl_lib_search_paths: &'a RefCell<HashSet<Path>>,
3434
pub triple: &'a str,
3535
}
3636

@@ -125,7 +125,7 @@ impl<'a> FileSearch<'a> {
125125

126126
pub fn new(sysroot: &'a Path,
127127
triple: &'a str,
128-
addl_lib_search_paths: &'a RefCell<Vec<Path>>) -> FileSearch<'a> {
128+
addl_lib_search_paths: &'a RefCell<HashSet<Path>>) -> FileSearch<'a> {
129129
debug!("using sysroot = {}, triple = {}", sysroot.display(), triple);
130130
FileSearch {
131131
sysroot: sysroot,
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright 2014 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+
// Checks that all rvalues in a crate have statically known size. check_crate
12+
// is the public starting point.
13+
14+
use middle::expr_use_visitor as euv;
15+
use middle::mem_categorization as mc;
16+
use middle::ty;
17+
use util::ppaux::ty_to_string;
18+
19+
use syntax::ast;
20+
use syntax::codemap::Span;
21+
use syntax::visit;
22+
23+
pub fn check_crate(tcx: &ty::ctxt,
24+
krate: &ast::Crate) {
25+
let mut rvcx = RvalueContext { tcx: tcx };
26+
visit::walk_crate(&mut rvcx, krate, ());
27+
}
28+
29+
struct RvalueContext<'a> {
30+
tcx: &'a ty::ctxt
31+
}
32+
33+
impl<'a> visit::Visitor<()> for RvalueContext<'a> {
34+
fn visit_fn(&mut self,
35+
_: &visit::FnKind,
36+
fd: &ast::FnDecl,
37+
b: &ast::Block,
38+
_: Span,
39+
_: ast::NodeId,
40+
_: ()) {
41+
let mut euv = euv::ExprUseVisitor::new(self, self.tcx);
42+
euv.walk_fn(fd, b);
43+
}
44+
}
45+
46+
impl<'a> euv::Delegate for RvalueContext<'a> {
47+
fn consume(&mut self,
48+
_: ast::NodeId,
49+
span: Span,
50+
cmt: mc::cmt,
51+
_: euv::ConsumeMode) {
52+
debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
53+
if !ty::type_is_sized(self.tcx, cmt.ty) {
54+
span_err!(self.tcx.sess, span, E0161,
55+
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
56+
ty_to_string(self.tcx, cmt.ty));
57+
}
58+
}
59+
60+
fn consume_pat(&mut self,
61+
_consume_pat: &ast::Pat,
62+
_cmt: mc::cmt,
63+
_mode: euv::ConsumeMode) {
64+
}
65+
66+
fn borrow(&mut self,
67+
_borrow_id: ast::NodeId,
68+
_borrow_span: Span,
69+
_cmt: mc::cmt,
70+
_loan_region: ty::Region,
71+
_bk: ty::BorrowKind,
72+
_loan_cause: euv::LoanCause) {
73+
}
74+
75+
fn decl_without_init(&mut self,
76+
_id: ast::NodeId,
77+
_span: Span) {
78+
}
79+
80+
fn mutate(&mut self,
81+
_assignment_id: ast::NodeId,
82+
_assignment_span: Span,
83+
_assignee_cmt: mc::cmt,
84+
_mode: euv::MutateMode) {
85+
}
86+
}

trunk/src/librustc/middle/mem_categorization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub enum MutabilityCategory {
150150
// like `*x`, the type of this deref node is the deref'd type (`T`),
151151
// but in a pattern like `@x`, the `@x` pattern is again a
152152
// dereference, but its type is the type *before* the dereference
153-
// (`@T`). So use `cmt.type` to find the type of the value in a consistent
153+
// (`@T`). So use `cmt.ty` to find the type of the value in a consistent
154154
// fashion. For more details, see the method `cat_pattern`
155155
#[deriving(Clone, PartialEq)]
156156
pub struct cmt_ {

trunk/src/librustdoc/core.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -80,7 +80,7 @@ pub struct CrateAnalysis {
8080
pub type Externs = HashMap<String, Vec<String>>;
8181

8282
/// Parses, resolves, and typechecks the given crate
83-
fn get_ast_and_resolve(cpath: &Path, libs: Vec<Path>, cfgs: Vec<String>,
83+
fn get_ast_and_resolve(cpath: &Path, libs: HashSet<Path>, cfgs: Vec<String>,
8484
externs: Externs, triple: Option<String>)
8585
-> (DocContext, CrateAnalysis) {
8686
use syntax::codemap::dummy_spanned;
@@ -153,7 +153,7 @@ fn get_ast_and_resolve(cpath: &Path, libs: Vec<Path>, cfgs: Vec<String>,
153153
})
154154
}
155155

156-
pub fn run_core(libs: Vec<Path>, cfgs: Vec<String>, externs: Externs,
156+
pub fn run_core(libs: HashSet<Path>, cfgs: Vec<String>, externs: Externs,
157157
path: &Path, triple: Option<String>)
158158
-> (clean::Crate, CrateAnalysis) {
159159
let (ctxt, analysis) = get_ast_and_resolve(path, libs, cfgs, externs, triple);

trunk/src/librustdoc/html/static/main.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
* A function to compute the Levenshtein distance between two strings
119119
* Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported
120120
* Full License can be found at http://creativecommons.org/licenses/by-sa/3.0/legalcode
121-
* This code is an unmodified version of the code written by Marco de Wit
121+
* This code is an unmodified version of the code written by Marco de Wit
122122
* and was found at http://stackoverflow.com/a/18514751/745719
123123
*/
124124
var levenshtein = (function() {
@@ -224,7 +224,7 @@
224224
});
225225
}
226226
} else if (
227-
(lev_distance = levenshtein(searchWords[j], val)) <=
227+
(lev_distance = levenshtein(searchWords[j], val)) <=
228228
MAX_LEV_DISTANCE) {
229229
if (typeFilter < 0 || typeFilter === searchIndex[j].ty) {
230230
results.push({
@@ -350,16 +350,16 @@
350350
function validateResult(name, path, keys, parent) {
351351
for (var i=0; i < keys.length; ++i) {
352352
// each check is for validation so we negate the conditions and invalidate
353-
if (!(
353+
if (!(
354354
// check for an exact name match
355355
name.toLowerCase().indexOf(keys[i]) > -1 ||
356356
// then an exact path match
357357
path.toLowerCase().indexOf(keys[i]) > -1 ||
358358
// next if there is a parent, check for exact parent match
359-
(parent !== undefined &&
359+
(parent !== undefined &&
360360
parent.name.toLowerCase().indexOf(keys[i]) > -1) ||
361361
// lastly check to see if the name was a levenshtein match
362-
levenshtein(name.toLowerCase(), keys[i]) <=
362+
levenshtein(name.toLowerCase(), keys[i]) <=
363363
MAX_LEV_DISTANCE)) {
364364
return false;
365365
}
@@ -757,21 +757,20 @@
757757
});
758758

759759
$(function() {
760-
var toggle = $("<a/>", {'href': 'javascript:void(0)', 'class': 'collapse-toggle'})
761-
.html("[<span class='inner'>-</span>]");
760+
var toggle = "<a href='javascript:void(0)'"
761+
+ "class='collapse-toggle'>[<span class='inner'>-</span>]</a>";
762762

763763
$(".method").each(function() {
764764
if ($(this).next().is(".docblock")) {
765-
$(this).children().first().after(toggle[0]);
765+
$(this).children().first().after(toggle);
766766
}
767767
});
768768

769-
var mainToggle =
770-
$(toggle).append(
771-
$('<span/>', {'class': 'toggle-label'})
772-
.css('display', 'none')
773-
.html('&nbsp;Expand&nbsp;description'));
774-
var wrapper = $("<div class='toggle-wrapper'>").append(mainToggle);
769+
var mainToggle = $(toggle);
770+
mainToggle.append("<span class='toggle-label' style='display:none'>"
771+
+ "&nbsp;Expand&nbsp;description</span></a>")
772+
var wrapper = $("<div class='toggle-wrapper'>");
773+
wrapper.append(mainToggle);
775774
$("#main > .docblock").before(wrapper);
776775
});
777776

trunk/src/librustdoc/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,11 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
369369
info!("starting to run rustc");
370370
let (mut krate, analysis) = std::task::try(proc() {
371371
let cr = cr;
372-
core::run_core(libs, cfgs, externs, &cr, triple)
372+
core::run_core(libs.move_iter().collect(),
373+
cfgs,
374+
externs,
375+
&cr,
376+
triple)
373377
}).map_err(|boxed_any|format!("{:?}", boxed_any)).unwrap();
374378
info!("finished with rustc");
375379
analysiskey.replace(Some(analysis));

trunk/src/librustdoc/markdown.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::collections::HashSet;
1112
use std::io;
1213
use std::string::String;
1314

@@ -135,7 +136,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
135136
}
136137

137138
/// Run any tests/code examples in the markdown file `input`.
138-
pub fn test(input: &str, libs: Vec<Path>, externs: core::Externs,
139+
pub fn test(input: &str, libs: HashSet<Path>, externs: core::Externs,
139140
mut test_args: Vec<String>) -> int {
140141
let input_str = load_or_return!(input, 1, 2);
141142

trunk/src/librustdoc/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use visit_ast::RustdocVisitor;
3939

4040
pub fn run(input: &str,
4141
cfgs: Vec<String>,
42-
libs: Vec<Path>,
42+
libs: HashSet<Path>,
4343
externs: core::Externs,
4444
mut test_args: Vec<String>,
4545
crate_name: Option<String>)
@@ -109,7 +109,7 @@ pub fn run(input: &str,
109109
0
110110
}
111111

112-
fn runtest(test: &str, cratename: &str, libs: Vec<Path>, externs: core::Externs,
112+
fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, externs: core::Externs,
113113
should_fail: bool, no_run: bool, as_test_harness: bool) {
114114
// the test harness wants its own `main` & top level functions, so
115115
// never wrap the test in `fn main() { ... }`
@@ -244,7 +244,7 @@ pub fn maketest(s: &str, cratename: Option<&str>, lints: bool, dont_insert_main:
244244
pub struct Collector {
245245
pub tests: Vec<testing::TestDescAndFn>,
246246
names: Vec<String>,
247-
libs: Vec<Path>,
247+
libs: HashSet<Path>,
248248
externs: core::Externs,
249249
cnt: uint,
250250
use_headers: bool,
@@ -253,7 +253,7 @@ pub struct Collector {
253253
}
254254

255255
impl Collector {
256-
pub fn new(cratename: String, libs: Vec<Path>, externs: core::Externs,
256+
pub fn new(cratename: String, libs: HashSet<Path>, externs: core::Externs,
257257
use_headers: bool) -> Collector {
258258
Collector {
259259
tests: Vec::new(),

trunk/src/test/compile-fail/dst-bad-assign-2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ pub fn main() {
4343
let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
4444
let z: Box<ToBar> = box Bar1 {f: 36};
4545
f5.ptr = *z; //~ ERROR dynamically sized type on lhs of assignment
46+
//~^ ERROR E0161
4647
}

trunk/src/test/compile-fail/dst-bad-deep.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ pub fn main() {
2222
let g: &Fat<[int]> = &f;
2323
let h: &Fat<Fat<[int]>> = &Fat { ptr: *g };
2424
//~^ ERROR trying to initialise a dynamically sized struct
25+
//~^^ ERROR E0161
2526
}

trunk/src/test/run-make/link-path-order/main.rs renamed to trunk/src/test/compile-fail/dst-rvalue.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
extern crate libc;
11+
// Check that dynamically sized rvalues are forbidden
1212

13-
#[link(name="foo")]
14-
extern {
15-
fn should_return_one() -> libc::c_int;
16-
}
17-
18-
fn main() {
19-
let result = unsafe {
20-
should_return_one()
21-
};
13+
pub fn main() {
14+
let _x: Box<str> = box *"hello world";
15+
//~^ ERROR E0161
2216

23-
if result != 1 {
24-
std::os::set_exit_status(255);
25-
}
17+
let array: &[int] = &[1, 2, 3];
18+
let _x: Box<[int]> = box *array;
19+
//~^ ERROR E0161
2620
}

0 commit comments

Comments
 (0)