Skip to content

Commit c9f4b9c

Browse files
committed
---
yaml --- r: 91007 b: refs/heads/master c: 5ff7b28 h: refs/heads/master i: 91005: 8ee5ef8 91003: 13e4cec 90999: 7a8103f 90991: face786 90975: 4a41a6e 90943: 8e08a6c 90879: 084ca3f v: v3
1 parent 7f6afef commit c9f4b9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+1014
-1050
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: 726091fea5ab7663c6e7c7cfdde015afc0065e46
2+
refs/heads/master: 5ff7b283731b795930d1e6782ae1639c83595e91
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
55
refs/heads/try: b160761e35efcd1207112b3b782c06633cf441a8

trunk/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ src/.DS_Store
7575
/doc/latex
7676
/doc/std
7777
/doc/extra
78+
/doc/green
79+
/doc/native
80+
/doc/rustc
81+
/doc/syntax
7882
/nd/
7983
/llvm/
8084
version.md

trunk/.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "src/llvm"]
22
path = src/llvm
3-
url = https://github.com/alexcrichton/llvm.git
3+
url = https://github.com/luqmana/llvm.git
44
branch = master
55
[submodule "src/libuv"]
66
path = src/libuv

trunk/doc/rust.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,12 @@ the behavior of the compiler.
610610

611611
~~~~
612612
// Package ID
613-
#[ pkgid = "projx#2.5" ];
613+
#[ crate_id = "projx#2.5" ];
614614
615615
// Additional metadata attributes
616616
#[ desc = "Project X" ];
617617
#[ license = "BSD" ];
618-
#[ author = "Jane Doe" ];
618+
#[ comment = "This is a comment on Project X." ];
619619
620620
// Specify the output type
621621
#[ crate_type = "lib" ];
@@ -776,9 +776,9 @@ as the `ident` provided in the `extern_mod_decl`.
776776
The external crate is resolved to a specific `soname` at compile time, and a
777777
runtime linkage requirement to that `soname` is passed to the linker for
778778
loading at runtime. The `soname` is resolved at compile time by scanning the
779-
compiler's library path and matching the optional `pkgid` provided as a string literal
780-
against the `pkgid` attributes that were declared on the external crate when
781-
it was compiled. If no `pkgid` is provided, a default `name` attribute is
779+
compiler's library path and matching the optional `crateid` provided as a string literal
780+
against the `crateid` attributes that were declared on the external crate when
781+
it was compiled. If no `crateid` is provided, a default `name` attribute is
782782
assumed, equal to the `ident` given in the `extern_mod_decl`.
783783

784784
Four examples of `extern mod` declarations:
@@ -1729,7 +1729,7 @@ names are effectively reserved. Some significant attributes include:
17291729
* The `cfg` attribute, for conditional-compilation by build-configuration.
17301730
* The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)).
17311731
* The `link` attribute, for describing linkage metadata for a extern blocks.
1732-
* The `pkgid` attribute, for describing the package ID of a crate.
1732+
* The `crate_id` attribute, for describing the package ID of a crate.
17331733
* The `test` attribute, for marking functions as unit tests.
17341734
* The `allow`, `warn`, `forbid`, and `deny` attributes, for
17351735
controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
@@ -3792,7 +3792,7 @@ specified then log level 4 is assumed. Debug messages can be omitted
37923792
by passing `--cfg ndebug` to `rustc`.
37933793

37943794
As an example, to see all the logs generated by the compiler, you would set
3795-
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `pkgid`
3795+
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `crate_id`
37963796
[attribute](#attributes)). To narrow down the logs to just crate resolution,
37973797
you would set it to `rustc::metadata::creader`. To see just error logging
37983798
use `rustc=0`.

trunk/doc/rustdoc.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ comments":
1313
~~~
1414
// the "link" crate attribute is currently required for rustdoc, but normally
1515
// isn't needed.
16-
#[pkgid = "universe"];
16+
#[crate_id = "universe"];
1717
#[crate_type="lib"];
1818
1919
//! Tools for dealing with universes (this is a doc comment, and is shown on
@@ -132,9 +132,10 @@ specifiers that can be used to dictate how a code block is tested:
132132
~~~
133133

134134
Rustdoc also supplies some extra sugar for helping with some tedious
135-
documentation examples. If a line is prefixed with a `#` character, then the
136-
line will not show up in the HTML documentation, but it will be used when
137-
testing the code block.
135+
documentation examples. If a line is prefixed with `# `, then the line
136+
will not show up in the HTML documentation, but it will be used when
137+
testing the code block (NB. the space after the `#` is required, so
138+
that one can still write things like `#[deriving(Eq)]`).
138139

139140
~~~
140141
```rust

trunk/doc/rustpkg.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ then both `bar` and `bar/extras/baz` are valid package identifiers
9090
in the workspace `foo`.
9191

9292
Because rustpkg uses generic source file names as the main inputs, you will
93-
need to specify the package identifier in them using the `pkgid` attribute
93+
need to specify the package identifier in them using the `crate_id` attribute
9494
on the crate.
9595

9696
## Source files

trunk/src/etc/combine-tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def scrub(b):
4545
"""
4646
// AUTO-GENERATED FILE: DO NOT EDIT
4747
#[crate_id=\"run_pass_stage2#0.1\"];
48-
#[pkgid=\"run_pass_stage2#0.1\"];
48+
#[crate_id=\"run_pass_stage2#0.1\"];
4949
#[feature(globs, macro_rules, struct_variant, managed_boxes)];
5050
#[allow(warnings)];
5151
"""

trunk/src/libextra/getopts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
//!
3232
//! ~~~{.rust}
3333
//! extern mod extra;
34-
//! use extra::getopts::*;
34+
//! use extra::getopts::{optopt,optflag,getopts,Opt};
3535
//! use std::os;
3636
//!
3737
//! fn do_work(inp: &str, out: Option<~str>) {

trunk/src/libextra/num/rational.rs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use std::cmp;
1515
use std::from_str::FromStr;
1616
use std::num::{Zero,One,ToStrRadix,FromStrRadix,Round};
17-
use super::bigint::BigInt;
17+
use super::bigint::{BigInt, BigUint, Sign, Plus, Minus};
1818

1919
/// Represents the ratio between 2 numbers.
2020
#[deriving(Clone)]
@@ -107,6 +107,27 @@ impl<T: Clone + Integer + Ord>
107107
}
108108
}
109109

110+
impl Ratio<BigInt> {
111+
/// Converts a float into a rational number
112+
pub fn from_float<T: Float>(f: T) -> Option<BigRational> {
113+
if !f.is_finite() {
114+
return None;
115+
}
116+
let (mantissa, exponent, sign) = f.integer_decode();
117+
let bigint_sign: Sign = if sign == 1 { Plus } else { Minus };
118+
if exponent < 0 {
119+
let one: BigInt = One::one();
120+
let denom: BigInt = one << ((-exponent) as uint);
121+
let numer: BigUint = FromPrimitive::from_u64(mantissa).unwrap();
122+
Some(Ratio::new(BigInt::from_biguint(bigint_sign, numer), denom))
123+
} else {
124+
let mut numer: BigUint = FromPrimitive::from_u64(mantissa).unwrap();
125+
numer = numer << (exponent as uint);
126+
Some(Ratio::from_integer(BigInt::from_biguint(bigint_sign, numer)))
127+
}
128+
}
129+
}
130+
110131
/* Comparisons */
111132

112133
// comparing a/b and c/d is the same as comparing a*d and b*c, so we
@@ -621,4 +642,42 @@ mod test {
621642
test(s);
622643
}
623644
}
645+
646+
#[test]
647+
fn test_from_float() {
648+
fn test<T: Float>(given: T, (numer, denom): (&str, &str)) {
649+
let ratio: BigRational = Ratio::from_float(given).unwrap();
650+
assert_eq!(ratio, Ratio::new(
651+
FromStr::from_str(numer).unwrap(),
652+
FromStr::from_str(denom).unwrap()));
653+
}
654+
655+
// f32
656+
test(3.14159265359f32, ("13176795", "4194304"));
657+
test(2f32.pow(&100.), ("1267650600228229401496703205376", "1"));
658+
test(-2f32.pow(&100.), ("-1267650600228229401496703205376", "1"));
659+
test(1.0 / 2f32.pow(&100.), ("1", "1267650600228229401496703205376"));
660+
test(684729.48391f32, ("1369459", "2"));
661+
test(-8573.5918555f32, ("-4389679", "512"));
662+
663+
// f64
664+
test(3.14159265359f64, ("3537118876014453", "1125899906842624"));
665+
test(2f64.pow(&100.), ("1267650600228229401496703205376", "1"));
666+
test(-2f64.pow(&100.), ("-1267650600228229401496703205376", "1"));
667+
test(684729.48391f64, ("367611342500051", "536870912"));
668+
test(-8573.5918555, ("-4713381968463931", "549755813888"));
669+
test(1.0 / 2f64.pow(&100.), ("1", "1267650600228229401496703205376"));
670+
}
671+
672+
#[test]
673+
fn test_from_float_fail() {
674+
use std::{f32, f64};
675+
676+
assert_eq!(Ratio::from_float(f32::NAN), None);
677+
assert_eq!(Ratio::from_float(f32::INFINITY), None);
678+
assert_eq!(Ratio::from_float(f32::NEG_INFINITY), None);
679+
assert_eq!(Ratio::from_float(f64::NAN), None);
680+
assert_eq!(Ratio::from_float(f64::INFINITY), None);
681+
assert_eq!(Ratio::from_float(f64::NEG_INFINITY), None);
682+
}
624683
}

trunk/src/libgreen/sched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ mod test {
14331433
drop(handle);
14341434

14351435
let mut handle = pool.spawn_sched();
1436-
handle.send(TaskFromFriend(pool.task(TaskOpts::new(), proc() {
1436+
handle.send(PinnedTask(pool.task(TaskOpts::new(), proc() {
14371437
// Wait until the other task has its lock
14381438
start_po.recv();
14391439

trunk/src/librustc/back/link.rs

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use back::archive::{Archive, METADATA_FILENAME};
1313
use back::rpath;
14-
use back::manifest;
1514
use driver::driver::CrateTranslation;
1615
use driver::session::Session;
1716
use driver::session;
@@ -41,7 +40,7 @@ use syntax::ast;
4140
use syntax::ast_map::{path, path_mod, path_name, path_pretty_name};
4241
use syntax::attr;
4342
use syntax::attr::AttrMetaMethods;
44-
use syntax::pkgid::PkgId;
43+
use syntax::crateid::CrateId;
4544

4645
#[deriving(Clone, Eq)]
4746
pub enum output_type {
@@ -444,13 +443,13 @@ pub mod write {
444443
*
445444
* So here is what we do:
446445
*
447-
* - Consider the package id; every crate has one (specified with pkgid
446+
* - Consider the package id; every crate has one (specified with crate_id
448447
* attribute). If a package id isn't provided explicitly, we infer a
449448
* versionless one from the output name. The version will end up being 0.0
450449
* in this case. CNAME and CVERS are taken from this package id. For
451450
* example, github.com/mozilla/CNAME#CVERS.
452451
*
453-
* - Define CMH as SHA256(pkgid).
452+
* - Define CMH as SHA256(crateid).
454453
*
455454
* - Define CMH8 as the first 8 characters of CMH.
456455
*
@@ -469,13 +468,13 @@ pub fn build_link_meta(sess: Session,
469468
symbol_hasher: &mut Sha256)
470469
-> LinkMeta {
471470
// This calculates CMH as defined above
472-
fn crate_hash(symbol_hasher: &mut Sha256, pkgid: &PkgId) -> @str {
471+
fn crate_hash(symbol_hasher: &mut Sha256, crateid: &CrateId) -> @str {
473472
symbol_hasher.reset();
474-
symbol_hasher.input_str(pkgid.to_str());
473+
symbol_hasher.input_str(crateid.to_str());
475474
truncated_hash_result(symbol_hasher).to_managed()
476475
}
477476

478-
let pkgid = match attr::find_pkgid(attrs) {
477+
let crateid = match attr::find_crateid(attrs) {
479478
None => {
480479
let stem = session::expect(
481480
sess,
@@ -487,10 +486,10 @@ pub fn build_link_meta(sess: Session,
487486
Some(s) => s,
488487
};
489488

490-
let hash = crate_hash(symbol_hasher, &pkgid);
489+
let hash = crate_hash(symbol_hasher, &crateid);
491490

492491
LinkMeta {
493-
pkgid: pkgid,
492+
crateid: crateid,
494493
crate_hash: hash,
495494
}
496495
}
@@ -509,7 +508,7 @@ pub fn symbol_hash(tcx: ty::ctxt,
509508
// to be independent of one another in the crate.
510509

511510
symbol_hasher.reset();
512-
symbol_hasher.input_str(link_meta.pkgid.name);
511+
symbol_hasher.input_str(link_meta.crateid.name);
513512
symbol_hasher.input_str("-");
514513
symbol_hasher.input_str(link_meta.crate_hash);
515514
symbol_hasher.input_str("-");
@@ -669,7 +668,7 @@ pub fn mangle_exported_name(ccx: &CrateContext,
669668
let hash = get_symbol_hash(ccx, t);
670669
return exported_name(ccx.sess, path,
671670
hash,
672-
ccx.link_meta.pkgid.version_or_default());
671+
ccx.link_meta.crateid.version_or_default());
673672
}
674673

675674
pub fn mangle_internal_name_by_type_only(ccx: &CrateContext,
@@ -710,9 +709,9 @@ pub fn mangle_internal_name_by_path(ccx: &CrateContext, path: path) -> ~str {
710709

711710
pub fn output_lib_filename(lm: &LinkMeta) -> ~str {
712711
format!("{}-{}-{}",
713-
lm.pkgid.name,
712+
lm.crateid.name,
714713
lm.crate_hash.slice_chars(0, 8),
715-
lm.pkgid.version_or_default())
714+
lm.crateid.version_or_default())
716715
}
717716

718717
pub fn get_cc_prog(sess: Session) -> ~str {
@@ -828,12 +827,6 @@ fn link_binary_output(sess: Session,
828827
}
829828
session::OutputExecutable => {
830829
link_natively(sess, false, obj_filename, &out_filename);
831-
// Windows linker will add an ".exe" extension if there was none
832-
let out_filename = match out_filename.extension() {
833-
Some(_) => out_filename.clone(),
834-
None => out_filename.with_extension(win32::EXE_EXTENSION)
835-
};
836-
manifest::postprocess_executable(sess, &out_filename);
837830
}
838831
session::OutputDylib => {
839832
link_natively(sess, true, obj_filename, &out_filename);

0 commit comments

Comments
 (0)