Skip to content

Commit e1878f7

Browse files
committed
---
yaml --- r: 108903 b: refs/heads/dist-snap c: e959c87 h: refs/heads/master i: 108901: d5a38e4 108899: 473ff86 108895: 81a0192 v: v3
1 parent 78bfd1e commit e1878f7

31 files changed

+125
-414
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 71cab0410f411c78dfe297bec5d35ad5a9e09d35
9+
refs/heads/dist-snap: e959c8794b80ffad3abd50f773e5a613e13ff7b2
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/metadata/loader.rs

Lines changed: 28 additions & 17 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 meatadata from: {}", flavor, lib.display());
302+
info!("{} reading metadata from: {}", flavor, lib.display());
303303
match get_metadata_section(self.os, &lib) {
304-
Some(blob) => {
304+
Ok(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-
None => {
312+
Err(_) => {
313313
info!("no metadata found");
314314
return None
315315
}
@@ -388,15 +388,18 @@ 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) -> Option<MetadataBlob> {
391+
fn get_metadata_section(os: Os, filename: &Path) -> Result<MetadataBlob, ~str> {
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) -> Option<MetadataBlob> {
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+
}
400403
if filename.filename_str().unwrap().ends_with(".rlib") {
401404
// Use ArchiveRO for speed here, it's backed by LLVM and uses mmap
402405
// internally to read the file. We also avoid even using a memcpy by
@@ -405,19 +408,26 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
405408
Some(ar) => ar,
406409
None => {
407410
debug!("llvm didn't like `{}`", filename.display());
408-
return None;
411+
return Err(format!("failed to read rlib metadata: '{}'",
412+
filename.display()));
409413
}
410414
};
411-
return ArchiveMetadata::new(archive).map(|ar| MetadataArchive(ar));
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+
}
412420
}
413421
unsafe {
414422
let mb = filename.with_c_str(|buf| {
415423
llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf)
416424
});
417-
if mb as int == 0 { return None }
425+
if mb as int == 0 {
426+
return Err(format!("error reading library: '{}'",filename.display()))
427+
}
418428
let of = match ObjectFile::new(mb) {
419429
Some(of) => of,
420-
_ => return None
430+
_ => return Err(format!("provided path not an object file: '{}'", filename.display()))
421431
};
422432
let si = mk_section_iter(of.llof);
423433
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
@@ -427,30 +437,31 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Option<MetadataBlob> {
427437
if read_meta_section_name(os) == name {
428438
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
429439
let csz = llvm::LLVMGetSectionSize(si.llsi) as uint;
430-
let mut found = None;
440+
let mut found = Err(format!("metadata not found: '{}'", filename.display()));
431441
let cvbuf: *u8 = cast::transmute(cbuf);
432442
let vlen = encoder::metadata_encoding_version.len();
433443
debug!("checking {} bytes of metadata-version stamp",
434444
vlen);
435445
let minsz = cmp::min(vlen, csz);
436446
let version_ok = vec::raw::buf_as_slice(cvbuf, minsz,
437447
|buf0| buf0 == encoder::metadata_encoding_version);
438-
if !version_ok { return None; }
448+
if !version_ok { return Err(format!("incompatible metadata version found: '{}'",
449+
filename.display()));}
439450

440451
let cvbuf1 = cvbuf.offset(vlen as int);
441452
debug!("inflating {} bytes of compressed metadata",
442453
csz - vlen);
443454
vec::raw::buf_as_slice(cvbuf1, csz-vlen, |bytes| {
444455
let inflated = flate::inflate_bytes(bytes);
445-
found = Some(MetadataVec(inflated));
456+
found = Ok(MetadataVec(inflated));
446457
});
447-
if found.is_some() {
458+
if found.is_ok() {
448459
return found;
449460
}
450461
}
451462
llvm::LLVMMoveToNextSection(si.llsi);
452463
}
453-
return None;
464+
return Err(format!("metadata not found: '{}'", filename.display()));
454465
}
455466
}
456467

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

branches/dist-snap/src/libstd/cell.rs

Lines changed: 1 addition & 8 deletions
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, DeepClone};
14+
use clone::Clone;
1515
use cmp::Eq;
1616
use fmt;
1717
use kinds::{marker, Pod};
@@ -222,13 +222,6 @@ 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-
232225
impl<T: Eq> Eq for RefCell<T> {
233226
fn eq(&self, other: &RefCell<T>) -> bool {
234227
let a = self.borrow();

branches/dist-snap/src/libstd/char.rs

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

11-
//! Unicode characters manipulation (`char` type)
11+
//! Character manipulation (`char` type, Unicode Scalar Value)
12+
//!
13+
//! This module provides the `Char` trait, as well as its implementation
14+
//! for the primitive `char` type, in order to allow basic character manipulation.
15+
//!
16+
//! A `char` actually represents a
17+
//! *[Unicode Scalar Value](http://www.unicode.org/glossary/#unicode_scalar_value)*,
18+
//! as it can contain any Unicode code point except high-surrogate and
19+
//! low-surrogate code points.
20+
//!
21+
//! As such, only values in the ranges \[0x0,0xD7FF\] and \[0xE000,0x10FFFF\]
22+
//! (inclusive) are allowed. A `char` can always be safely cast to a `u32`;
23+
//! however the converse is not always true due to the above range limits
24+
//! and, as such, should be performed via the `from_u32` function..
25+
1226

1327
use cast::transmute;
1428
use option::{None, Option, Some};
@@ -66,7 +80,7 @@ static TAG_FOUR_B: uint = 240u;
6680
/// The highest valid code point
6781
pub static MAX: char = '\U0010ffff';
6882

69-
/// Convert from `u32` to a character.
83+
/// Converts from `u32` to a `char`
7084
#[inline]
7185
pub fn from_u32(i: u32) -> Option<char> {
7286
// catch out-of-bounds and surrogates
@@ -77,31 +91,44 @@ pub fn from_u32(i: u32) -> Option<char> {
7791
}
7892
}
7993

80-
/// Returns whether the specified character is considered a unicode alphabetic
81-
/// character
94+
/// Returns whether the specified `char` is considered a Unicode alphabetic
95+
/// code point
8296
pub fn is_alphabetic(c: char) -> bool { derived_property::Alphabetic(c) }
83-
#[allow(missing_doc)]
97+
98+
/// Returns whether the specified `char` satisfies the 'XID_Start' Unicode property
99+
///
100+
/// 'XID_Start' is a Unicode Derived Property specified in
101+
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
102+
/// mostly similar to ID_Start but modified for closure under NFKx.
84103
pub fn is_XID_start(c: char) -> bool { derived_property::XID_Start(c) }
85-
#[allow(missing_doc)]
104+
105+
/// Returns whether the specified `char` satisfies the 'XID_Continue' Unicode property
106+
///
107+
/// 'XID_Continue' is a Unicode Derived Property specified in
108+
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
109+
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
86110
pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) }
87111

88112
///
89-
/// Indicates whether a character is in lower case, defined
90-
/// in terms of the Unicode Derived Core Property 'Lowercase'.
113+
/// Indicates whether a `char` is in lower case
114+
///
115+
/// This is defined according to the terms of the Unicode Derived Core Property 'Lowercase'.
91116
///
92117
#[inline]
93118
pub fn is_lowercase(c: char) -> bool { derived_property::Lowercase(c) }
94119

95120
///
96-
/// Indicates whether a character is in upper case, defined
97-
/// in terms of the Unicode Derived Core Property 'Uppercase'.
121+
/// Indicates whether a `char` is in upper case
122+
///
123+
/// This is defined according to the terms of the Unicode Derived Core Property 'Uppercase'.
98124
///
99125
#[inline]
100126
pub fn is_uppercase(c: char) -> bool { derived_property::Uppercase(c) }
101127

102128
///
103-
/// Indicates whether a character is whitespace. Whitespace is defined in
104-
/// terms of the Unicode Property 'White_Space'.
129+
/// Indicates whether a `char` is whitespace
130+
///
131+
/// Whitespace is defined in terms of the Unicode Property 'White_Space'.
105132
///
106133
#[inline]
107134
pub fn is_whitespace(c: char) -> bool {
@@ -112,9 +139,10 @@ pub fn is_whitespace(c: char) -> bool {
112139
}
113140

114141
///
115-
/// Indicates whether a character is alphanumeric. Alphanumericness is
116-
/// defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No'
117-
/// and the Derived Core Property 'Alphabetic'.
142+
/// Indicates whether a `char` is alphanumeric
143+
///
144+
/// Alphanumericness is defined in terms of the Unicode General Categories
145+
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
118146
///
119147
#[inline]
120148
pub fn is_alphanumeric(c: char) -> bool {
@@ -125,14 +153,15 @@ pub fn is_alphanumeric(c: char) -> bool {
125153
}
126154

127155
///
128-
/// Indicates whether a character is a control character. Control
129-
/// characters are defined in terms of the Unicode General Category
156+
/// Indicates whether a `char` is a control code point
157+
///
158+
/// Control code points are defined in terms of the Unicode General Category
130159
/// 'Cc'.
131160
///
132161
#[inline]
133162
pub fn is_control(c: char) -> bool { general_category::Cc(c) }
134163

135-
/// Indicates whether the character is numeric (Nd, Nl, or No)
164+
/// Indicates whether the `char` is numeric (Nd, Nl, or No)
136165
#[inline]
137166
pub fn is_digit(c: char) -> bool {
138167
general_category::Nd(c)
@@ -141,7 +170,8 @@ pub fn is_digit(c: char) -> bool {
141170
}
142171

143172
///
144-
/// Checks if a character parses as a numeric digit in the given radix.
173+
/// Checks if a `char` parses as a numeric digit in the given radix
174+
///
145175
/// Compared to `is_digit()`, this function only recognizes the
146176
/// characters `0-9`, `a-z` and `A-Z`.
147177
///
@@ -167,13 +197,13 @@ pub fn is_digit_radix(c: char, radix: uint) -> bool {
167197
}
168198

169199
///
170-
/// Convert a char to the corresponding digit.
200+
/// Converts a `char` to the corresponding digit
171201
///
172202
/// # Return value
173203
///
174204
/// If `c` is between '0' and '9', the corresponding value
175205
/// between 0 and 9. If `c` is 'a' or 'A', 10. If `c` is
176-
/// 'b' or 'B', 11, etc. Returns none if the char does not
206+
/// 'b' or 'B', 11, etc. Returns none if the `char` does not
177207
/// refer to a digit in the given radix.
178208
///
179209
/// # Failure
@@ -196,7 +226,7 @@ pub fn to_digit(c: char, radix: uint) -> Option<uint> {
196226
}
197227

198228
///
199-
/// Converts a number to the character representing it.
229+
/// Converts a number to the character representing it
200230
///
201231
/// # Return value
202232
///
@@ -254,7 +284,7 @@ fn decompose_hangul(s: char, f: |char|) {
254284
}
255285
}
256286

257-
/// Returns the canonical decomposition of a character.
287+
/// Returns the canonical decomposition of a character
258288
pub fn decompose_canonical(c: char, f: |char|) {
259289
if (c as uint) < S_BASE || (c as uint) >= (S_BASE + S_COUNT) {
260290
decompose::canonical(c, f);
@@ -263,7 +293,7 @@ pub fn decompose_canonical(c: char, f: |char|) {
263293
}
264294
}
265295

266-
/// Returns the compatibility decomposition of a character.
296+
/// Returns the compatibility decomposition of a character
267297
pub fn decompose_compatible(c: char, f: |char|) {
268298
if (c as uint) < S_BASE || (c as uint) >= (S_BASE + S_COUNT) {
269299
decompose::compatibility(c, f);
@@ -273,7 +303,7 @@ pub fn decompose_compatible(c: char, f: |char|) {
273303
}
274304

275305
///
276-
/// Return the hexadecimal unicode escape of a char.
306+
/// Returns the hexadecimal Unicode escape of a `char`
277307
///
278308
/// The rules are as follows:
279309
///
@@ -301,7 +331,7 @@ pub fn escape_unicode(c: char, f: |char|) {
301331
}
302332

303333
///
304-
/// Return a 'default' ASCII and C++11-like char-literal escape of a char.
334+
/// Returns a 'default' ASCII and C++11-like literal escape of a `char`
305335
///
306336
/// The default is chosen with a bias toward producing literals that are
307337
/// legal in a variety of languages, including C++11 and similar C-family
@@ -325,7 +355,7 @@ pub fn escape_default(c: char, f: |char|) {
325355
}
326356
}
327357

328-
/// Returns the amount of bytes this character would need if encoded in utf8
358+
/// Returns the amount of bytes this `char` would need if encoded in UTF-8
329359
pub fn len_utf8_bytes(c: char) -> uint {
330360
static MAX_ONE_B: uint = 128u;
331361
static MAX_TWO_B: uint = 2048u;
@@ -360,8 +390,9 @@ pub trait Char {
360390
fn escape_default(&self, f: |char|);
361391
fn len_utf8_bytes(&self) -> uint;
362392

363-
/// Encodes this character as utf-8 into the provided byte-buffer. The
364-
/// buffer must be at least 4 bytes long or a runtime failure will occur.
393+
/// Encodes this `char` as utf-8 into the provided byte-buffer
394+
///
395+
/// The buffer must be at least 4 bytes long or a runtime failure will occur.
365396
///
366397
/// This will then return the number of characters written to the slice.
367398
fn encode_utf8(&self, dst: &mut [u8]) -> uint;

0 commit comments

Comments
 (0)