Skip to content

Rolling up some more PRs #13397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,17 @@ distcheck-osx: dist-osx
# Unix binary installer tarballs
######################################################################

define DEF_INSTALLER

$$(eval $$(call DEF_PREPARE,dir-$(1)))

dist-install-dir-$(1): PREPARE_HOST=$(1)
dist-install-dir-$(1): PREPARE_TARGETS=$(1)
dist-install-dir-$(1): PREPARE_DEST_DIR=tmp/dist/$$(PKG_NAME)-$(1)
dist-install-dir-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-install-dir-$(1): PREPARE_CLEAN=true
dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs
define DEF_PREPARE_DIST_DIR

dist-install-dir-$(1)$(3): PREPARE_HOST=$(1)
dist-install-dir-$(1)$(3): PREPARE_TARGETS=$(2)
dist-install-dir-$(1)$(3): PREPARE_DEST_DIR=tmp/dist/$$(PKG_NAME)-$(1)
dist-install-dir-$(1)$(3): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
dist-install-dir-$(1)$(3): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-install-dir-$(1)$(3): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-install-dir-$(1)$(3): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-install-dir-$(1)$(3): PREPARE_CLEAN=true
dist-install-dir-$(1)$(3): prepare-base-dir-$(1) docs compiler-docs
$$(Q)(cd $$(PREPARE_DEST_DIR)/ && find . -type f | sed 's/^\.\///') \
> tmp/dist/manifest-$(1).in
$$(Q)mv tmp/dist/manifest-$(1).in $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest.in
Expand All @@ -227,6 +225,16 @@ dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs
$$(Q)cp -r doc $$(PREPARE_DEST_DIR)
$$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR)

endef

define DEF_INSTALLER

$$(eval $$(call DEF_PREPARE,dir-$(1)))

$$(eval $$(call DEF_PREPARE_DIST_DIR,$(1),$(1),))

$$(eval $$(call DEF_PREPARE_DIST_DIR,$(1),$(CFG_TARGET),-with-target-libs))

dist/$$(PKG_NAME)-$(1).tar.gz: dist-install-dir-$(1)
@$(call E, build: $$@)
$$(Q)tar -czf dist/$$(PKG_NAME)-$(1).tar.gz -C tmp/dist $$(PKG_NAME)-$(1)
Expand Down
4 changes: 2 additions & 2 deletions mk/install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ else
MAYBE_DISABLE_VERIFY=
endif

install: dist-install-dir-$(CFG_BUILD)
install: dist-install-dir-$(CFG_BUILD)-with-target-libs
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)" "$(MAYBE_DISABLE_VERIFY)"
# Remove tmp files while we can because they may have been created under sudo
$(Q)rm -R tmp/dist

uninstall: dist-install-dir-$(CFG_BUILD)
uninstall: dist-install-dir-$(CFG_BUILD)-with-target-libs
$(Q)sh tmp/dist/$(PKG_NAME)-$(CFG_BUILD)/install.sh --uninstall --prefix="$(DESTDIR)$(CFG_PREFIX)" --libdir="$(DESTDIR)$(CFG_LIBDIR)" --mandir="$(DESTDIR)$(CFG_MANDIR)"
# Remove tmp files while we can because they may have been created under sudo
$(Q)rm -R tmp/dist
Expand Down
2 changes: 1 addition & 1 deletion src/doc/complement-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ struct Foo {
}

struct FooClosure<'a> {
myfunc: 'a |int, uint| -> i32
myfunc: |int, uint|: 'a -> i32
}

fn a(a: int, b: uint) -> i32 {
Expand Down
49 changes: 47 additions & 2 deletions src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ operators](#binary-operator-expressions), or [keywords](#keywords).
## Paths

~~~~ {.notrust .ebnf .gram}
expr_path : ident [ "::" expr_path_tail ] + ;
expr_path : [ "::" ] ident [ "::" expr_path_tail ] + ;
expr_path_tail : '<' type_expr [ ',' type_expr ] + '>'
| expr_path ;

Expand Down Expand Up @@ -475,6 +475,51 @@ let x = id::<int>(10); // Type arguments used in a call expression
# }
~~~~

Paths can be denoted with various leading qualifiers to change the meaning of
how it is resolved:

* Paths starting with `::` are considered to be global paths where the
components of the path start being resolved from the crate root. Each
identifier in the path must resolve to an item.

```rust
mod a {
pub fn foo() {}
}
mod b {
pub fn foo() {
::a::foo(); // call a's foo function
}
}
# fn main() {}
```

* Paths starting with the keyword `super` begin resolution relative to the
parent module. Each further identifier must resolve to an item

```rust
mod a {
pub fn foo() {}
}
mod b {
pub fn foo() {
super::a::foo(); // call a's foo function
}
}
# fn main() {}
```

* Paths starting with the keyword `self` begin resolution relative to the
current module. Each further identifier must resolve to an item.

```rust
fn foo() {}
fn bar() {
self::foo();
}
# fn main() {}
```

# Syntax extensions

A number of minor features of Rust are not central enough to have their own
Expand Down Expand Up @@ -3415,7 +3460,7 @@ fn add(x: int, y: int) -> int {

let mut x = add(5,7);

type Binop<'a> = 'a |int,int| -> int;
type Binop<'a> = |int,int|: 'a -> int;
let bo: Binop = add;
x = bo(5,7);
~~~~
Expand Down
5 changes: 3 additions & 2 deletions src/etc/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ def do_license_check(name, contents):
check_tab = False
if line.find(linelength_flag) != -1:
check_linelength = False
if line.find("// XXX") != -1:
report_err("XXX is no longer necessary, use FIXME")
if line.find("TODO") != -1:
report_err("TODO is deprecated; use FIXME")
match = re.match(r'^.*/(\*|/!?)\s*XXX', line)
if match:
report_err("XXX is no longer necessary, use FIXME")
match = re.match(r'^.*//\s*(NOTE.*)$', line)
if match:
m = match.group(1)
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub mod bench {
map.insert(*k, 1);
}

rng.shuffle_mut(keys);
rng.shuffle(keys);

// measure
let mut i = 0;
Expand Down
34 changes: 20 additions & 14 deletions src/libflate/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,49 @@ static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal"
static TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1; // parse zlib header and adler32 checksum
static TDEFL_WRITE_ZLIB_HEADER : c_int = 0x01000; // write zlib header and adler32 checksum

fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> CVec<u8> {
fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
unsafe {
let mut outsz : size_t = 0;
let res = rustrt::tdefl_compress_mem_to_heap(bytes.as_ptr() as *c_void,
bytes.len() as size_t,
&mut outsz,
flags);
assert!(!res.is_null());
CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res))
if !res.is_null() {
Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res)))
} else {
None
}
}
}

pub fn deflate_bytes(bytes: &[u8]) -> CVec<u8> {
pub fn deflate_bytes(bytes: &[u8]) -> Option<CVec<u8>> {
deflate_bytes_internal(bytes, LZ_NORM)
}

pub fn deflate_bytes_zlib(bytes: &[u8]) -> CVec<u8> {
pub fn deflate_bytes_zlib(bytes: &[u8]) -> Option<CVec<u8>> {
deflate_bytes_internal(bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER)
}

fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> CVec<u8> {
fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<CVec<u8>> {
unsafe {
let mut outsz : size_t = 0;
let res = rustrt::tinfl_decompress_mem_to_heap(bytes.as_ptr() as *c_void,
bytes.len() as size_t,
&mut outsz,
flags);
assert!(!res.is_null());
CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res))
if !res.is_null() {
Some(CVec::new_with_dtor(res as *mut u8, outsz as uint, proc() libc::free(res)))
} else {
None
}
}
}

pub fn inflate_bytes(bytes: &[u8]) -> CVec<u8> {
pub fn inflate_bytes(bytes: &[u8]) -> Option<CVec<u8>> {
inflate_bytes_internal(bytes, 0)
}

pub fn inflate_bytes_zlib(bytes: &[u8]) -> CVec<u8> {
pub fn inflate_bytes_zlib(bytes: &[u8]) -> Option<CVec<u8>> {
inflate_bytes_internal(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER)
}

Expand All @@ -117,8 +123,8 @@ mod tests {
}
debug!("de/inflate of {} bytes of random word-sequences",
input.len());
let cmp = deflate_bytes(input);
let out = inflate_bytes(cmp.as_slice());
let cmp = deflate_bytes(input).expect("deflation failed");
let out = inflate_bytes(cmp.as_slice()).expect("inflation failed");
debug!("{} bytes deflated to {} ({:.1f}% size)",
input.len(), cmp.len(),
100.0 * ((cmp.len() as f64) / (input.len() as f64)));
Expand All @@ -129,8 +135,8 @@ mod tests {
#[test]
fn test_zlib_flate() {
let bytes = vec!(1, 2, 3, 4, 5);
let deflated = deflate_bytes(bytes.as_slice());
let inflated = inflate_bytes(deflated.as_slice());
let deflated = deflate_bytes(bytes.as_slice()).expect("deflation failed");
let inflated = inflate_bytes(deflated.as_slice()).expect("inflation failed");
assert_eq!(inflated.as_slice(), bytes.as_slice());
}
}
4 changes: 2 additions & 2 deletions src/libgreen/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn event_loop() -> ~EventLoop:Send {
}

struct BasicLoop {
work: ~[proc:Send()], // pending work
work: ~[proc():Send], // pending work
idle: Option<*mut BasicPausable>, // only one is allowed
remotes: ~[(uint, ~Callback:Send)],
next_remote: uint,
Expand Down Expand Up @@ -135,7 +135,7 @@ impl EventLoop for BasicLoop {
}
}

fn callback(&mut self, f: proc:Send()) {
fn callback(&mut self, f: proc():Send) {
self.work.push(f);
}

Expand Down
9 changes: 1 addition & 8 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

#![feature(globs)]
#![crate_id = "libc#0.10-pre"]
#![crate_id = "libc#0.11-pre"]
#![experimental]
#![no_std] // we don't need std, and we can't have std, since it doesn't exist
// yet. std depends on us.
Expand Down Expand Up @@ -75,8 +75,6 @@
#![allow(missing_doc)]
#![allow(uppercase_variables)]

#![feature(link_args)] // NOTE: remove after stage0

#[cfg(test)] extern crate std;
#[cfg(test)] extern crate test;
#[cfg(test)] extern crate native;
Expand Down Expand Up @@ -199,11 +197,6 @@ pub use funcs::posix88::unistd::{rmdir, unlink, write};
#[link(name = "m")]
extern {}

// NOTE: remove this after a stage0 snap
#[cfg(stage0, windows)]
#[link_args = "-Wl,--enable-long-section-names"]
extern {}

/// A wrapper for a nullable pointer. Don't use this except for interacting
/// with libc. Basically Option, but without the dependance on libstd.
// If/when libprim happens, this can be removed in favor of that
Expand Down
Empty file added src/libnative/io/p
Empty file.
4 changes: 2 additions & 2 deletions src/libnative/io/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ fn spawn_process_os(config: p::ProcessConfig,
}

#[cfg(unix)]
fn with_argv<T>(prog: &str, args: &[~str], cb: proc:(**libc::c_char) -> T) -> T {
fn with_argv<T>(prog: &str, args: &[~str], cb: proc(**libc::c_char) -> T) -> T {
use std::slice;

// We can't directly convert `str`s into `*char`s, as someone needs to hold
Expand All @@ -635,7 +635,7 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: proc:(**libc::c_char) -> T) -> T
}

#[cfg(unix)]
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: proc:(*c_void) -> T) -> T {
fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: proc(*c_void) -> T) -> T {
use std::slice;

// On posixy systems we can pass a char** for envp, which is a
Expand Down
6 changes: 3 additions & 3 deletions src/libnative/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ fn ops() -> ~Ops {
}

/// Spawns a function with the default configuration
pub fn spawn(f: proc:Send()) {
pub fn spawn(f: proc():Send) {
spawn_opts(TaskOpts::new(), f)
}

/// Spawns a new task given the configuration options and a procedure to run
/// inside the task.
pub fn spawn_opts(opts: TaskOpts, f: proc:Send()) {
pub fn spawn_opts(opts: TaskOpts, f: proc():Send) {
let TaskOpts {
notify_chan, name, stack_size,
stderr, stdout,
Expand Down Expand Up @@ -238,7 +238,7 @@ impl rt::Runtime for Ops {
}
}

fn spawn_sibling(~self, mut cur_task: ~Task, opts: TaskOpts, f: proc:Send()) {
fn spawn_sibling(~self, mut cur_task: ~Task, opts: TaskOpts, f: proc():Send) {
cur_task.put_runtime(self);
Local::put(cur_task);

Expand Down
4 changes: 2 additions & 2 deletions src/librand/distributions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ fn ziggurat<R:Rng>(
symmetric: bool,
x_tab: ziggurat_tables::ZigTable,
f_tab: ziggurat_tables::ZigTable,
pdf: 'static |f64| -> f64,
zero_case: 'static |&mut R, f64| -> f64)
pdf: |f64|: 'static -> f64,
zero_case: |&mut R, f64|: 'static -> f64)
-> f64 {
static SCALE: f64 = (1u64 << 53) as f64;
loop {
Expand Down
2 changes: 1 addition & 1 deletion src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ mod test {
#[test]
fn test_shuffle() {
let mut r = task_rng();
let mut empty: &mut [int] = &mut [];
let empty: &mut [int] = &mut [];
r.shuffle(empty);
let mut one = [1];
r.shuffle(one);
Expand Down
7 changes: 5 additions & 2 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,14 @@ fn link_rlib<'a>(sess: &'a Session,
let bc_deflated = obj_filename.with_extension("bc.deflate");
match fs::File::open(&bc).read_to_end().and_then(|data| {
fs::File::create(&bc_deflated)
.write(flate::deflate_bytes(data.as_slice()).as_slice())
.write(match flate::deflate_bytes(data.as_slice()) {
Some(compressed) => compressed,
None => sess.fatal("failed to compress bytecode")
}.as_slice())
}) {
Ok(()) => {}
Err(e) => {
sess.err(format!("failed to compress bytecode: {}", e));
sess.err(format!("failed to write compressed bytecode: {}", e));
sess.abort_if_errors()
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/librustc/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
archive.read(format!("{}.bc.deflate", name)));
let bc = bc.expect("missing compressed bytecode in archive!");
let bc = time(sess.time_passes(), format!("inflate {}.bc", name), (), |_|
flate::inflate_bytes(bc));
match flate::inflate_bytes(bc) {
Some(bc) => bc,
None => sess.fatal(format!("failed to decompress bc of `{}`", name))
});
let ptr = bc.as_slice().as_ptr();
debug!("linking {}", name);
time(sess.time_passes(), format!("ll link {}", name), (), |()| unsafe {
Expand Down
2 changes: 0 additions & 2 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ pub fn phase_2_configure_and_expand(sess: &Session,
cfg,
krate)
});
// dump the syntax-time crates
sess.cstore.reset();

// strip again, in case expansion added anything with a #[cfg].
krate = time(time_passes, "configuration 2", krate, |krate|
Expand Down
Loading