Skip to content

Commit 2af62e7

Browse files
committed
---
yaml --- r: 149821 b: refs/heads/try2 c: 71cab04 h: refs/heads/master i: 149819: 52789cd v: v3
1 parent 3c2f646 commit 2af62e7

34 files changed

+437
-135
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: 5d1d285623f8d454a62ca16cf8ec2533aad23305
8+
refs/heads/try2: 71cab0410f411c78dfe297bec5d35ad5a9e09d35
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/doc/rustdoc.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,24 @@ code block.
117117
// This is a testable code block (4-space indent)
118118
~~~
119119

120-
In addition to the `ignore` directive, you can specify that the test's execution
121-
should fail with the `should_fail` directive.
120+
You can specify that the test's execution should fail with the `should_fail`
121+
directive.
122122

123123
~~~
124124
```should_fail
125125
// This code block is expected to generate a failure when run
126126
```
127127
~~~
128128

129+
You can specify that the code block should be compiled but not run with the
130+
`no_run` directive.
131+
132+
~~~
133+
```no_run
134+
// This code will be compiled but not executed
135+
```
136+
~~~
137+
129138
Rustdoc also supplies some extra sugar for helping with some tedious
130139
documentation examples. If a line is prefixed with `# `, then the line
131140
will not show up in the HTML documentation, but it will be used when

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

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,17 @@ impl<'a> Context<'a> {
299299

300300
let lib = m.move_iter().next().unwrap();
301301
if slot.is_none() {
302-
info!("{} reading metadata from: {}", flavor, lib.display());
302+
info!("{} reading meatadata from: {}", flavor, lib.display());
303303
match get_metadata_section(self.os, &lib) {
304-
Ok(blob) => {
304+
Some(blob) => {
305305
if self.crate_matches(blob.as_slice()) {
306306
*slot = Some(blob);
307307
} else {
308308
info!("metadata mismatch");
309309
return None;
310310
}
311311
}
312-
Err(_) => {
312+
None => {
313313
info!("no metadata found");
314314
return None
315315
}
@@ -388,18 +388,15 @@ impl ArchiveMetadata {
388388
}
389389

390390
// Just a small wrapper to time how long reading metadata takes.
391-
fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, ~str> {
391+
fn get_metadata_section(os: Os, filename: &Path) -> Option<MetadataBlob> {
392392
let start = time::precise_time_ns();
393393
let ret = get_metadata_section_imp(os, filename);
394394
info!("reading {} => {}ms", filename.filename_display(),
395395
(time::precise_time_ns() - start) / 1000000);
396396
return ret;
397397
}
398398

399-
fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~str> {
400-
if !filename.exists() {
401-
return Err(format!("no such file: '{}'", filename.display()));
402-
}
399+
fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
403400
if filename.filename_str().unwrap().ends_with(".rlib") {
404401
// Use ArchiveRO for speed here, it's backed by LLVM and uses mmap
405402
// internally to read the file. We also avoid even using a memcpy by
@@ -408,26 +405,19 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
408405
Some(ar) => ar,
409406
None => {
410407
debug!("llvm didn't like `{}`", filename.display());
411-
return Err(format!("failed to read rlib metadata: '{}'",
412-
filename.display()));
408+
return None;
413409
}
414410
};
415-
return match ArchiveMetadata::new(archive).map(|ar| MetadataArchive(ar)) {
416-
None => return Err(format!("failed to read rlib metadata: '{}'",
417-
filename.display())),
418-
Some(blob) => return Ok(blob)
419-
}
411+
return ArchiveMetadata::new(archive).map(|ar| MetadataArchive(ar));
420412
}
421413
unsafe {
422414
let mb = filename.with_c_str(|buf| {
423415
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
424416
});
425-
if mb as int == 0 {
426-
return Err(format!("error reading library: '{}'",filename.display()))
427-
}
417+
if mb as int == 0 { return None }
428418
let of = match ObjectFile::new(mb) {
429419
Some(of) => of,
430-
_ => return Err(format!("provided path not an object file: '{}'", filename.display()))
420+
_ => return None
431421
};
432422
let si = mk_section_iter(of.llof);
433423
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
@@ -437,31 +427,30 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
437427
if read_meta_section_name(os) == name {
438428
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
439429
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
440-
let mut found = Err(format!("metadata not found: '{}'", filename.display()));
430+
let mut found = None;
441431
let cvbuf: *u8 = cast::transmute(cbuf);
442432
let vlen = encoder::metadata_encoding_version.len();
443433
debug!("checking {} bytes of metadata-version stamp",
444434
vlen);
445435
let minsz = cmp::min(vlen, csz);
446436
let version_ok = vec::raw::buf_as_slice(cvbuf, minsz,
447437
|buf0| buf0 == encoder::metadata_encoding_version);
448-
if !version_ok { return Err(format!("incompatible metadata version found: '{}'",
449-
filename.display()));}
438+
if !version_ok { return None; }
450439

451440
let cvbuf1 = cvbuf.offset(vlen as int);
452441
debug!("inflating {} bytes of compressed metadata",
453442
csz - vlen);
454443
vec::raw::buf_as_slice(cvbuf1, csz-vlen, |bytes| {
455444
let inflated = flate::inflate_bytes(bytes);
456-
found = Ok(MetadataVec(inflated));
445+
found = Some(MetadataVec(inflated));
457446
});
458-
if found.is_ok() {
447+
if found.is_some() {
459448
return found;
460449
}
461450
}
462451
llvm::LLVMMoveToNextSection(si.llsi);
463452
}
464-
return Err(format!("metadata not found: '{}'", filename.display()));
453+
return None;
465454
}
466455
}
467456

@@ -489,9 +478,9 @@ pub fn read_meta_section_name(os: Os) -> &'static str {
489478
pub fn list_file_metadata(os: Os, path: &Path,
490479
out: &mut io::Writer) -> io::IoResult<()> {
491480
match get_metadata_section(os, path) {
492-
Ok(bytes) => decoder::list_crate_metadata(bytes.as_slice(), out),
493-
Err(msg) => {
494-
write!(out, "{}\n", msg)
481+
Some(bytes) => decoder::list_crate_metadata(bytes.as_slice(), out),
482+
None => {
483+
write!(out, "could not find metadata in {}.\n", path.display())
495484
}
496485
}
497486
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,15 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
245245
extern fn block(_ob: *buf, text: *buf, lang: *buf, opaque: *libc::c_void) {
246246
unsafe {
247247
if text.is_null() { return }
248-
let (shouldfail, ignore) = if lang.is_null() {
249-
(false, false)
248+
let (should_fail, no_run, ignore) = if lang.is_null() {
249+
(false, false, false)
250250
} else {
251251
vec::raw::buf_as_slice((*lang).data,
252252
(*lang).size as uint, |lang| {
253253
let s = str::from_utf8(lang).unwrap();
254-
(s.contains("should_fail"), s.contains("ignore") ||
255-
s.contains("notrust"))
254+
(s.contains("should_fail"),
255+
s.contains("no_run"),
256+
s.contains("ignore") || s.contains("notrust"))
256257
})
257258
};
258259
if ignore { return }
@@ -261,7 +262,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
261262
let text = str::from_utf8(text).unwrap();
262263
let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l));
263264
let text = lines.to_owned_vec().connect("\n");
264-
tests.add_test(text, shouldfail);
265+
tests.add_test(text, should_fail, no_run);
265266
})
266267
}
267268
}

branches/try2/src/librustdoc/test.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
9898
0
9999
}
100100

101-
fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool) {
101+
fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool,
102+
no_run: bool) {
102103
let test = maketest(test, cratename);
103104
let parsesess = parse::new_parse_sess();
104105
let input = driver::StrInput(test);
@@ -152,6 +153,8 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool)
152153
let cfg = driver::build_configuration(sess);
153154
driver::compile_input(sess, cfg, &input, &out, &None);
154155

156+
if no_run { return }
157+
155158
// Run the code!
156159
let exe = outdir.path().join("rust_out");
157160
let out = Process::output(exe.as_str().unwrap(), []);
@@ -203,7 +206,7 @@ pub struct Collector {
203206
}
204207

205208
impl Collector {
206-
pub fn add_test(&mut self, test: &str, should_fail: bool) {
209+
pub fn add_test(&mut self, test: &str, should_fail: bool, no_run: bool) {
207210
let test = test.to_owned();
208211
let name = format!("{}_{}", self.names.connect("::"), self.cnt);
209212
self.cnt += 1;
@@ -218,7 +221,7 @@ impl Collector {
218221
should_fail: false, // compiler failures are test failures
219222
},
220223
testfn: testing::DynTestFn(proc() {
221-
runtest(test, cratename, libs, should_fail);
224+
runtest(test, cratename, libs, should_fail, no_run);
222225
}),
223226
});
224227
}

branches/try2/src/libstd/cell.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Types dealing with dynamic mutability
1212
1313
use cast;
14-
use clone::Clone;
14+
use clone::{Clone, DeepClone};
1515
use cmp::Eq;
1616
use fmt;
1717
use kinds::{marker, Pod};
@@ -222,6 +222,13 @@ impl<T: Clone> Clone for RefCell<T> {
222222
}
223223
}
224224

225+
impl<T: DeepClone> DeepClone for RefCell<T> {
226+
fn deep_clone(&self) -> RefCell<T> {
227+
let x = self.borrow();
228+
RefCell::new(x.get().deep_clone())
229+
}
230+
}
231+
225232
impl<T: Eq> Eq for RefCell<T> {
226233
fn eq(&self, other: &RefCell<T>) -> bool {
227234
let a = self.borrow();

0 commit comments

Comments
 (0)