Skip to content

Commit c08a74e

Browse files
committed
---
yaml --- r: 110170 b: refs/heads/auto c: 94a055c h: refs/heads/master v: v3
1 parent f76f72c commit c08a74e

File tree

20 files changed

+329
-269
lines changed

20 files changed

+329
-269
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 28938d08a09c016cdb23eb2e56d803454a82918b
16+
refs/heads/auto: 94a055c7295bd5822219b86243c2af6fff9d21d3
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/doc/rust.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,12 @@ The keywords are the following strings:
206206
as
207207
break
208208
crate
209-
do
210209
else enum extern
211210
false fn for
212211
if impl in
213212
let loop
214213
match mod mut
215-
priv pub
214+
priv proc pub
216215
ref return
217216
self static struct super
218217
true trait type
@@ -2558,12 +2557,12 @@ task in a _failing state_.
25582557

25592558
~~~~ {.ignore}
25602559
# use std::task;
2561-
# do task::spawn {
2560+
# task::spawn(proc() {
25622561
25632562
([1, 2, 3, 4])[0];
25642563
(["a", "b"])[10]; // fails
25652564
2566-
# }
2565+
# })
25672566
~~~~
25682567

25692568
### Unary operator expressions

branches/auto/src/doc/rustdoc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ that one can still write things like `#[deriving(Eq)]`).
165165
# // what's actually being documented.
166166
# fn fib(n: int) { n + 2 }
167167

168-
do spawn { fib(200); }
168+
spawn(proc() { fib(200); })
169169
```
170170
*/
171171
# fn foo() {}
172172

173-
The documentation online would look like `do spawn { fib(200); }`, but when
173+
The documentation online would look like `spawn(proc() { fib(200); })`, but when
174174
testing this code, the `fib` function will be included (so it can compile).
175175

176176
## Running tests (advanced)

branches/auto/src/doc/tutorial.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,8 @@ Rust uses the unary star operator (`*`) to access the contents of a
14921492
box or pointer, similarly to C.
14931493
14941494
~~~
1495-
let owned = ~20;
1496-
let borrowed = &30;
1495+
let owned = ~10;
1496+
let borrowed = &20;
14971497

14981498
let sum = *owned + *borrowed;
14991499
~~~
@@ -1520,7 +1520,7 @@ can sometimes make code awkward and parenthesis-filled.
15201520
# struct Point { x: f64, y: f64 }
15211521
# enum Shape { Rectangle(Point, Point) }
15221522
# impl Shape { fn area(&self) -> int { 0 } }
1523-
let start = @Point { x: 10.0, y: 20.0 };
1523+
let start = ~Point { x: 10.0, y: 20.0 };
15241524
let end = ~Point { x: (*start).x + 100.0, y: (*start).y + 100.0 };
15251525
let rect = &Rectangle(*start, *end);
15261526
let area = (*rect).area();
@@ -1534,7 +1534,7 @@ dot), so in most cases, explicitly dereferencing the receiver is not necessary.
15341534
# struct Point { x: f64, y: f64 }
15351535
# enum Shape { Rectangle(Point, Point) }
15361536
# impl Shape { fn area(&self) -> int { 0 } }
1537-
let start = @Point { x: 10.0, y: 20.0 };
1537+
let start = ~Point { x: 10.0, y: 20.0 };
15381538
let end = ~Point { x: start.x + 100.0, y: start.y + 100.0 };
15391539
let rect = &Rectangle(*start, *end);
15401540
let area = rect.area();
@@ -1546,7 +1546,7 @@ something silly like
15461546
15471547
~~~
15481548
# struct Point { x: f64, y: f64 }
1549-
let point = &@~Point { x: 10.0, y: 20.0 };
1549+
let point = &~Point { x: 10.0, y: 20.0 };
15501550
println!("{:f}", point.x);
15511551
~~~
15521552
@@ -1907,7 +1907,6 @@ to a reference.
19071907
// As with typical function arguments, owned pointers
19081908
// are automatically converted to references
19091909

1910-
(@s).draw_reference();
19111910
(~s).draw_reference();
19121911

19131912
// Unlike typical function arguments, the self value will
@@ -1918,7 +1917,7 @@ s.draw_reference();
19181917
(& &s).draw_reference();
19191918

19201919
// ... and dereferenced and borrowed
1921-
(&@~s).draw_reference();
1920+
(&~s).draw_reference();
19221921
~~~
19231922
19241923
Implementations may also define standalone (sometimes called "static")
@@ -2403,7 +2402,7 @@ that, like strings and vectors, objects have dynamic size and may
24032402
only be referred to via one of the pointer types.
24042403
Other pointer types work as well.
24052404
Casts to traits may only be done with compatible pointers so,
2406-
for example, an `@Circle` may not be cast to an `~Drawable`.
2405+
for example, an `&Circle` may not be cast to an `~Drawable`.
24072406
24082407
~~~
24092408
# type Circle = int; type Rectangle = int;
@@ -2506,8 +2505,8 @@ use std::f64::consts::PI;
25062505
# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI).sqrt() } }
25072506
# impl Shape for CircleStruct { fn area(&self) -> f64 { PI * square(self.radius) } }
25082507
2509-
let concrete = @CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2510-
let mycircle: @Circle = concrete as @Circle;
2508+
let concrete = ~CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2509+
let mycircle: ~Circle = concrete as ~Circle;
25112510
let nonsense = mycircle.radius() * mycircle.area();
25122511
~~~
25132512

branches/auto/src/librustc/driver/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
323323
let region_map = time(time_passes, "region resolution", (), |_|
324324
middle::region::resolve_crate(&sess, krate));
325325

326+
time(time_passes, "loop checking", (), |_|
327+
middle::check_loop::check_crate(&sess, krate));
328+
326329
let ty_cx = ty::mk_ctxt(sess, def_map, named_region_map, ast_map,
327330
freevars, region_map, lang_items);
328331

@@ -348,9 +351,6 @@ pub fn phase_3_run_analysis_passes(sess: Session,
348351
time(time_passes, "effect checking", (), |_|
349352
middle::effect::check_crate(&ty_cx, method_map, krate));
350353

351-
time(time_passes, "loop checking", (), |_|
352-
middle::check_loop::check_crate(&ty_cx, krate));
353-
354354
let middle::moves::MoveMaps {moves_map, moved_variables_set,
355355
capture_map} =
356356
time(time_passes, "compute moves", (), |_|

branches/auto/src/librustc/driver/session.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ impl Session {
232232
pub fn span_end_note(&self, sp: Span, msg: &str) {
233233
self.diagnostic().span_end_note(sp, msg)
234234
}
235+
pub fn fileline_note(&self, sp: Span, msg: &str) {
236+
self.diagnostic().fileline_note(sp, msg)
237+
}
235238
pub fn note(&self, msg: &str) {
236239
self.diagnostic().handler().note(msg)
237240
}

branches/auto/src/librustc/metadata/creader.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use metadata::cstore;
2121
use metadata::decoder;
2222
use metadata::loader;
2323
use metadata::loader::Os;
24+
use metadata::loader::CratePaths;
2425

2526
use std::cell::RefCell;
2627
use std::rc::Rc;
@@ -141,7 +142,7 @@ fn visit_view_item(e: &mut Env, i: &ast::ViewItem) {
141142

142143
match extract_crate_info(e, i) {
143144
Some(info) => {
144-
let cnum = resolve_crate(e, None, info.ident, &info.crate_id, None,
145+
let cnum = resolve_crate(e, &None, info.ident, &info.crate_id, None,
145146
i.span);
146147
e.sess.cstore.add_extern_mod_stmt_cnum(info.id, cnum);
147148
}
@@ -278,13 +279,13 @@ fn existing_match(e: &Env, crate_id: &CrateId,
278279
None
279280
}
280281

281-
fn resolve_crate(e: &mut Env,
282-
root_ident: Option<&str>,
283-
ident: &str,
284-
crate_id: &CrateId,
285-
hash: Option<&Svh>,
286-
span: Span)
287-
-> ast::CrateNum {
282+
fn resolve_crate<'a>(e: &mut Env,
283+
root: &Option<CratePaths>,
284+
ident: &str,
285+
crate_id: &CrateId,
286+
hash: Option<&Svh>,
287+
span: Span)
288+
-> ast::CrateNum {
288289
match existing_match(e, crate_id, hash) {
289290
None => {
290291
let id_hash = link::crate_id_hash(crate_id);
@@ -297,11 +298,11 @@ fn resolve_crate(e: &mut Env,
297298
hash: hash.map(|a| &*a),
298299
os: e.os,
299300
intr: e.intr.clone(),
300-
rejected_via_hash: false,
301+
rejected_via_hash: vec!(),
301302
};
302303
let loader::Library {
303304
dylib, rlib, metadata
304-
} = load_ctxt.load_library_crate(root_ident);
305+
} = load_ctxt.load_library_crate(root);
305306

306307
let crate_id = decoder::get_crate_id(metadata.as_slice());
307308
let hash = decoder::get_crate_hash(metadata.as_slice());
@@ -316,15 +317,22 @@ fn resolve_crate(e: &mut Env,
316317
});
317318
e.next_crate_num += 1;
318319

319-
// Maintain a reference to the top most crate.
320-
let root_crate = match root_ident {
321-
Some(c) => c,
322-
None => load_ctxt.ident.clone()
320+
// Stash paths for top-most crate locally if necessary.
321+
let crate_paths = if root.is_none() {
322+
Some(CratePaths {
323+
ident: load_ctxt.ident.to_owned(),
324+
dylib: dylib.clone(),
325+
rlib: rlib.clone(),
326+
})
327+
} else {
328+
None
323329
};
330+
// Maintain a reference to the top most crate.
331+
let root = if root.is_some() { root } else { &crate_paths };
324332

325333
// Now resolve the crates referenced by this crate
326334
let cnum_map = resolve_crate_deps(e,
327-
Some(root_crate),
335+
root,
328336
metadata.as_slice(),
329337
span);
330338

@@ -349,7 +357,7 @@ fn resolve_crate(e: &mut Env,
349357

350358
// Go through the crate metadata and load any crates that it references
351359
fn resolve_crate_deps(e: &mut Env,
352-
root_ident: Option<&str>,
360+
root: &Option<CratePaths>,
353361
cdata: &[u8], span : Span)
354362
-> cstore::cnum_map {
355363
debug!("resolving deps of external crate");
@@ -360,7 +368,7 @@ fn resolve_crate_deps(e: &mut Env,
360368
for dep in r.iter() {
361369
let extrn_cnum = dep.cnum;
362370
debug!("resolving dep crate {} hash: `{}`", dep.crate_id, dep.hash);
363-
let local_cnum = resolve_crate(e, root_ident,
371+
let local_cnum = resolve_crate(e, root,
364372
dep.crate_id.name.as_slice(),
365373
&dep.crate_id,
366374
Some(&dep.hash),
@@ -393,7 +401,7 @@ impl<'a> Loader<'a> {
393401
impl<'a> CrateLoader for Loader<'a> {
394402
fn load_crate(&mut self, krate: &ast::ViewItem) -> MacroCrate {
395403
let info = extract_crate_info(&self.env, krate).unwrap();
396-
let cnum = resolve_crate(&mut self.env, None, info.ident,
404+
let cnum = resolve_crate(&mut self.env, &None, info.ident,
397405
&info.crate_id, None, krate.span);
398406
let library = self.env.sess.cstore.get_used_crate_source(cnum).unwrap();
399407
MacroCrate {

branches/auto/src/librustc/metadata/loader.rs

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ pub enum Os {
4646
OsFreebsd
4747
}
4848

49+
pub struct HashMismatch {
50+
path: Path,
51+
}
52+
4953
pub struct Context<'a> {
5054
pub sess: &'a Session,
5155
pub span: Span,
@@ -55,7 +59,7 @@ pub struct Context<'a> {
5559
pub hash: Option<&'a Svh>,
5660
pub os: Os,
5761
pub intr: Rc<IdentInterner>,
58-
pub rejected_via_hash: bool,
62+
pub rejected_via_hash: Vec<HashMismatch>
5963
}
6064

6165
pub struct Library {
@@ -70,6 +74,23 @@ pub struct ArchiveMetadata {
7074
data: &'static [u8],
7175
}
7276

77+
pub struct CratePaths {
78+
pub ident: ~str,
79+
pub dylib: Option<Path>,
80+
pub rlib: Option<Path>
81+
}
82+
83+
impl CratePaths {
84+
fn paths(&self) -> Vec<Path> {
85+
match (&self.dylib, &self.rlib) {
86+
(&None, &None) => vec!(),
87+
(&Some(ref p), &None) |
88+
(&None, &Some(ref p)) => vec!(p.clone()),
89+
(&Some(ref p1), &Some(ref p2)) => vec!(p1.clone(), p2.clone()),
90+
}
91+
}
92+
}
93+
7394
// FIXME(#11857) this should be a "real" realpath
7495
fn realpath(p: &Path) -> Path {
7596
use std::os;
@@ -83,26 +104,43 @@ fn realpath(p: &Path) -> Path {
83104
}
84105

85106
impl<'a> Context<'a> {
86-
pub fn load_library_crate(&mut self, root_ident: Option<&str>) -> Library {
107+
pub fn load_library_crate(&mut self, root: &Option<CratePaths>) -> Library {
87108
match self.find_library_crate() {
88109
Some(t) => t,
89110
None => {
90111
self.sess.abort_if_errors();
91-
let message = if self.rejected_via_hash {
112+
let message = if self.rejected_via_hash.len() > 0 {
92113
format!("found possibly newer version of crate `{}`",
93114
self.ident)
94115
} else {
95116
format!("can't find crate for `{}`", self.ident)
96117
};
97-
let message = match root_ident {
98-
None => message,
99-
Some(c) => format!("{} which `{}` depends on", message, c),
118+
let message = match root {
119+
&None => message,
120+
&Some(ref r) => format!("{} which `{}` depends on",
121+
message, r.ident)
100122
};
101123
self.sess.span_err(self.span, message);
102124

103-
if self.rejected_via_hash {
125+
if self.rejected_via_hash.len() > 0 {
104126
self.sess.span_note(self.span, "perhaps this crate needs \
105127
to be recompiled?");
128+
let mismatches = self.rejected_via_hash.iter();
129+
for (i, &HashMismatch{ ref path }) in mismatches.enumerate() {
130+
self.sess.fileline_note(self.span,
131+
format!("crate `{}` path \\#{}: {}",
132+
self.ident, i+1, path.display()));
133+
}
134+
match root {
135+
&None => {}
136+
&Some(ref r) => {
137+
for (i, path) in r.paths().iter().enumerate() {
138+
self.sess.fileline_note(self.span,
139+
format!("crate `{}` path \\#{}: {}",
140+
r.ident, i+1, path.display()));
141+
}
142+
}
143+
}
106144
}
107145
self.sess.abort_if_errors();
108146
unreachable!()
@@ -292,7 +330,7 @@ impl<'a> Context<'a> {
292330
info!("{} reading metadata from: {}", flavor, lib.display());
293331
let metadata = match get_metadata_section(self.os, &lib) {
294332
Ok(blob) => {
295-
if self.crate_matches(blob.as_slice()) {
333+
if self.crate_matches(blob.as_slice(), &lib) {
296334
blob
297335
} else {
298336
info!("metadata mismatch");
@@ -327,7 +365,7 @@ impl<'a> Context<'a> {
327365
return if error > 0 {None} else {ret}
328366
}
329367

330-
fn crate_matches(&mut self, crate_data: &[u8]) -> bool {
368+
fn crate_matches(&mut self, crate_data: &[u8], libpath: &Path) -> bool {
331369
match decoder::maybe_get_crate_id(crate_data) {
332370
Some(ref id) if self.crate_id.matches(id) => {}
333371
_ => return false
@@ -339,7 +377,7 @@ impl<'a> Context<'a> {
339377
None => true,
340378
Some(myhash) => {
341379
if *myhash != hash {
342-
self.rejected_via_hash = true;
380+
self.rejected_via_hash.push(HashMismatch{ path: libpath.clone() });
343381
false
344382
} else {
345383
true

0 commit comments

Comments
 (0)