From 293b57701b7bcdd88e44ce8f671511ba35cac13e Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Mon, 29 Sep 2014 19:58:32 -0700 Subject: [PATCH 01/43] Add missing case for pointer -> int when translating constant cast expressions Closes issue #17458 --- src/librustc/middle/trans/consts.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index d39fe4a1e70..456ff69e0ec 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -547,6 +547,9 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, (expr::cast_integral, expr::cast_pointer) => { llvm::LLVMConstIntToPtr(v, llty.to_ref()) } + (expr::cast_pointer, expr::cast_integral) => { + llvm::LLVMConstPtrToInt(v, llty.to_ref()) + } _ => { cx.sess().impossible_case(e.span, "bad combination of types for cast") From 7c9db32f828729a415f4c334cb69f485e3b84d3d Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Tue, 30 Sep 2014 19:48:17 -0700 Subject: [PATCH 02/43] Disallow casting directly between C-like enums and unsafe pointers This closes issue #17444 --- src/librustc/middle/typeck/check/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index d4c38d48a8c..c051782a83b 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1468,7 +1468,7 @@ fn check_cast(fcx: &FnCtxt, // casts to scalars other than `char` and `bare fn` are trivial let t_1_is_trivial = t_1_is_scalar && !t_1_is_char && !t_1_is_bare_fn; if ty::type_is_c_like_enum(fcx.tcx(), t_e) && t_1_is_trivial { - if t_1_is_float { + if t_1_is_float || ty::type_is_unsafe_ptr(t_1) { fcx.type_error_message(span, |actual| { format!("illegal cast; cast through an \ integer first: `{}` as `{}`", From eb8b36973db4fc0340f8f5345b67410d68af5115 Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Mon, 29 Sep 2014 20:22:29 -0700 Subject: [PATCH 03/43] Add regression test for issue #17458 --- src/test/run-pass/issue-17458.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/run-pass/issue-17458.rs diff --git a/src/test/run-pass/issue-17458.rs b/src/test/run-pass/issue-17458.rs new file mode 100644 index 00000000000..a32a31e97e3 --- /dev/null +++ b/src/test/run-pass/issue-17458.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static X: uint = 0 as *const uint as uint; + +fn main() { + assert_eq!(X, 0); +} From 93408be7884754a3a661412c6be940cc1e9691d7 Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Mon, 29 Sep 2014 20:22:43 -0700 Subject: [PATCH 04/43] Add regression test for issue #17444 --- src/test/compile-fail/issue-17444.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/test/compile-fail/issue-17444.rs diff --git a/src/test/compile-fail/issue-17444.rs b/src/test/compile-fail/issue-17444.rs new file mode 100644 index 00000000000..33777e820ed --- /dev/null +++ b/src/test/compile-fail/issue-17444.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Test { + Foo = 0 +} + +fn main() { + let _x = Foo as *const int; + //~^ ERROR illegal cast; cast through an integer first: `Test` as `*const int` +} From 3dc32a1dedb26c2e4ede9a1c822419c0ed0dd676 Mon Sep 17 00:00:00 2001 From: Kevin Walter Date: Wed, 1 Oct 2014 16:09:38 +0200 Subject: [PATCH 05/43] Fix async assertion in test_sendable_future --- src/libstd/sync/future.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 78da605143d..621c08fe7bc 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -201,12 +201,13 @@ mod test { #[test] fn test_sendable_future() { let expected = "schlorf"; + let (tx, rx) = channel(); let f = Future::spawn(proc() { expected }); task::spawn(proc() { let mut f = f; - let actual = f.get(); - assert_eq!(actual, expected); + tx.send(f.get()); }); + assert_eq!(rx.recv(), expected); } #[test] From 1dfb23f4cf5c8a7224cf9d71a0d0b74f22ad252d Mon Sep 17 00:00:00 2001 From: "NODA, Kai" Date: Wed, 1 Oct 2014 19:38:21 +0800 Subject: [PATCH 06/43] librustc/driver: expose build information of rustc. CFG_RELEASE, CFG_VER_HASH and CFG_VER_DATE were only available as an output to stdout from the driver::version() function that had an inconvenient signature. --- src/librustc/driver/mod.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs index d9ccfd26010..95ff2703be8 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc/driver/mod.rs @@ -128,6 +128,21 @@ fn run_compiler(args: &[String]) { driver::compile_input(sess, cfg, &input, &odir, &ofile, None); } +/// Returns a version string such as "0.12.0-dev". +pub fn release_str() -> Option<&'static str> { + option_env!("CFG_RELEASE") +} + +/// Returns the full SHA1 hash of HEAD of the Git repo from which rustc was built. +pub fn commit_hash_str() -> Option<&'static str> { + option_env!("CFG_VER_HASH") +} + +/// Returns the "commit date" of HEAD of the Git repo from which rustc was built as a static string. +pub fn commit_date_str() -> Option<&'static str> { + option_env!("CFG_VER_DATE") +} + /// Prints version information and returns None on success or an error /// message on failure. pub fn version(binary: &str, matches: &getopts::Matches) -> Option { @@ -137,13 +152,14 @@ pub fn version(binary: &str, matches: &getopts::Matches) -> Option { Some(s) => return Some(format!("Unrecognized argument: {}", s)) }; - println!("{} {}", binary, env!("CFG_VERSION")); + println!("{} {}", binary, option_env!("CFG_VERSION").unwrap_or("unknown version")); if verbose { + fn unw(x: Option<&str>) -> &str { x.unwrap_or("unknown") } println!("binary: {}", binary); - println!("commit-hash: {}", option_env!("CFG_VER_HASH").unwrap_or("unknown")); - println!("commit-date: {}", option_env!("CFG_VER_DATE").unwrap_or("unknown")); + println!("commit-hash: {}", unw(commit_hash_str())); + println!("commit-date: {}", unw(commit_date_str())); println!("host: {}", driver::host_triple()); - println!("release: {}", env!("CFG_RELEASE")); + println!("release: {}", unw(release_str())); } None } From ac956c013f5064eadc14e581b833dfddd173a206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Str=C3=A1nsk=C3=BD?= Date: Wed, 1 Oct 2014 22:20:58 +0200 Subject: [PATCH 07/43] Guide: clarify exporting Mention that using `pub` is called exporting. Remove that `use` is called re-exporting, because `pub use` should be called re-exporting. The guide currently doesn't cover `pub use`. --- src/doc/guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 074dfc17b0d..a00fa5668db 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -2727,7 +2727,8 @@ mod hello { } ``` -This will work: +Usage of the `pub` keyword is sometimes called 'exporting', because +we're making the function available for other modules. This will work: ```{notrust,ignore} $ cargo run @@ -3291,8 +3292,7 @@ use super::times_four; Because we've made a nested module, we can import functions from the parent module by using `super`. Sub-modules are allowed to 'see' private functions in -the parent. We sometimes call this usage of `use` a 're-export,' because we're -exporting the name again, somewhere else. +the parent. We've now covered the basics of testing. Rust's tools are primitive, but they work well in the simple cases. There are some Rustaceans working on building From fc818ff33b8b83ec1c669660acab37fc6576eee4 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 1 Oct 2014 17:10:59 -0400 Subject: [PATCH 08/43] =?UTF-8?q?:fire:=20=CF=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #17674 --- src/doc/guide-lifetimes.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/doc/guide-lifetimes.md b/src/doc/guide-lifetimes.md index 66faee3fa04..545d286c5d7 100644 --- a/src/doc/guide-lifetimes.md +++ b/src/doc/guide-lifetimes.md @@ -305,10 +305,9 @@ copying. # Circle(Point, f64), // origin, radius # Rectangle(Point, Size) // upper-left, dimensions # } -# static tau: f64 = 6.28; fn compute_area(shape: &Shape) -> f64 { match *shape { - Circle(_, radius) => 0.5 * tau * radius * radius, + Circle(_, radius) => 2.0 * std::f64::consts::PI * radius * radius, Rectangle(_, ref size) => size.w * size.h } } @@ -316,10 +315,7 @@ fn compute_area(shape: &Shape) -> f64 { The first case matches against circles. Here, the pattern extracts the radius from the shape variant and the action uses it to compute the -area of the circle. (Like any up-to-date engineer, we use the [tau -circle constant][tau] and not that dreadfully outdated notion of pi). - -[tau]: http://www.math.utah.edu/~palais/pi.html +area of the circle. The second match is more interesting. Here we match against a rectangle and extract its size: but rather than copy the `size` From ee1cbb9c71bfab8500dfabedb35ba63dd1e5b7ff Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 1 Oct 2014 17:12:29 -0400 Subject: [PATCH 09/43] use similar syntax in all arms Fixes #17672 --- src/doc/guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 074dfc17b0d..ac3a58ad39c 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -2030,7 +2030,7 @@ fn main() { match cmp(input, secret_number) { Less => println!("Too small!"), Greater => println!("Too big!"), - Equal => { println!("You win!"); }, + Equal => println!("You win!"), } } From e2357cf41b69c6db57bbf53c63f59376576c72ae Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 1 Oct 2014 17:14:29 -0400 Subject: [PATCH 10/43] Don't compare () to null. Fixes #17671. --- src/doc/guide.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index ac3a58ad39c..30bb48ffccb 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -659,14 +659,12 @@ error: mismatched types: expected `int` but found `()` (expected int but found ( ``` We expected an integer, but we got `()`. `()` is pronounced 'unit', and is a -special type in Rust's type system. `()` is different than `null` in other -languages, because `()` is distinct from other types. For example, in C, `null` -is a valid value for a variable of type `int`. In Rust, `()` is _not_ a valid -value for a variable of type `int`. It's only a valid value for variables of -the type `()`, which aren't very useful. Remember how we said statements don't -return a value? Well, that's the purpose of unit in this case. The semicolon -turns any expression into a statement by throwing away its value and returning -unit instead. +special type in Rust's type system. In Rust, `()` is _not_ a valid value for a +variable of type `int`. It's only a valid value for variables of the type `()`, +which aren't very useful. Remember how we said statements don't return a value? +Well, that's the purpose of unit in this case. The semicolon turns any +expression into a statement by throwing away its value and returning unit +instead. There's one more time in which you won't see a semicolon at the end of a line of Rust code. For that, we'll need our next concept: functions. From dc35a53d15527e5618d9531b4452bae857f60169 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 1 Oct 2014 17:16:34 -0400 Subject: [PATCH 11/43] Fix incorrect statement about ok() Fixes #17676. --- src/doc/guide.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 30bb48ffccb..3ffb7cad0a4 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -1678,11 +1678,11 @@ just `int`s. Rust provides a method on these `IoResult`s called `ok()`, which does the same thing as our `match` statement, but assuming that we have a valid value. -If we don't, it will terminate our program. In this case, if we can't get -input, our program doesn't work, so we're okay with that. In most cases, we -would want to handle the error case explicitly. The result of `ok()` has a -method, `expect()`, which allows us to give an error message if this crash -happens. +We then call `expect()` on the result, which will terminate our program if we +don't have a valid value. In this case, if we can't get input, our program +doesn't work, so we're okay with that. In most cases, we would want to handle +the error case explicitly. `expect()` allows us to give an error message if +this crash happens. We will cover the exact details of how all of this works later in the Guide. For now, this gives you enough of a basic understanding to work with. From 9115a7353cddb5600cc36c1d37f1722bd0bd71d3 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 2 Oct 2014 03:33:00 +0200 Subject: [PATCH 12/43] Fix `make TAGS.vi` target Remove superfluous parentheses from the CTAGS_LOCATIONS expression. Fixes the following error when executing `make TAGS.vi`: /bin/sh: -c: line 0: syntax error near unexpected token `)' --- mk/ctags.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mk/ctags.mk b/mk/ctags.mk index 93a04e4c93f..44a16d556be 100644 --- a/mk/ctags.mk +++ b/mk/ctags.mk @@ -28,7 +28,7 @@ CTAGS_LOCATIONS=$(patsubst ${CFG_SRC_DIR}src/llvm,, \ $(patsubst ${CFG_SRC_DIR}src/rt/sundown,, \ $(patsubst ${CFG_SRC_DIR}src/rt/vg,, \ $(wildcard ${CFG_SRC_DIR}src/*) $(wildcard ${CFG_SRC_DIR}src/rt/*) \ - ))))))))))) + ))))))))) CTAGS_OPTS=--options="${CFG_SRC_DIR}src/etc/ctags.rust" --languages=-javascript --recurse ${CTAGS_LOCATIONS} # We could use `--languages=Rust`, but there is value in producing tags for the # C++ parts of the code base too (at the time of writing, those are .h and .cpp From 45fd7cd3592d4cc400cbb3d47e869814de98220c Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 2 Oct 2014 17:35:20 +1300 Subject: [PATCH 13/43] Enable a test for .. in range patterns. --- src/test/compile-fail/pat-range-bad-dots.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/compile-fail/pat-range-bad-dots.rs b/src/test/compile-fail/pat-range-bad-dots.rs index b3c436f6d2b..5605caaeeed 100644 --- a/src/test/compile-fail/pat-range-bad-dots.rs +++ b/src/test/compile-fail/pat-range-bad-dots.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - pub fn main() { match 22i { 0 .. 3 => {} //~ ERROR expected `=>`, found `..` From 497b6354e41af8bdabc8beb379db01fd2066b4af Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 2 Oct 2014 05:01:10 -0400 Subject: [PATCH 14/43] rm obsolete valgrind suppressions --- src/etc/x86.supp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/etc/x86.supp b/src/etc/x86.supp index 42e426b5399..58eb109d860 100644 --- a/src/etc/x86.supp +++ b/src/etc/x86.supp @@ -373,14 +373,6 @@ fun:_ZN4llvm4UsernwEjj } -{ - libuv-0-byte-realloc - Memcheck:Leak - fun:malloc - ... - fun:*uv_loop_delete* -} - { race-or-something-ask-pcwalton-0 Memcheck:Value4 @@ -502,15 +494,3 @@ fun:* ... } - -{ - libuv-mac-no-thread-join - Memcheck:Leak - fun:malloc_zone_malloc - fun:_CFRuntimeCreateInstance - fun:CFRunLoopSourceCreate - fun:uv__platform_loop_init - fun:uv__loop_init - fun:uv_loop_new - ... -} From 7b3eb432329975494e682362befc24e67ade5aa1 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 2 Oct 2014 05:03:49 -0400 Subject: [PATCH 15/43] rm libuv-auto-clean-trigger --- src/rt/libuv-auto-clean-trigger | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 src/rt/libuv-auto-clean-trigger diff --git a/src/rt/libuv-auto-clean-trigger b/src/rt/libuv-auto-clean-trigger deleted file mode 100644 index 8bd7aa54751..00000000000 --- a/src/rt/libuv-auto-clean-trigger +++ /dev/null @@ -1,2 +0,0 @@ -# Change the contents of this file to force a full rebuild of libuv -2014-04-18 From 618e41874a1ef47a6629524016bd8d9ffce617bc Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 2 Oct 2014 05:05:12 -0400 Subject: [PATCH 16/43] remove the uv_support code --- mk/rt.mk | 3 +- src/rt/rust_uv.c | 169 ----------------------------------------------- 2 files changed, 1 insertion(+), 171 deletions(-) delete mode 100644 src/rt/rust_uv.c diff --git a/mk/rt.mk b/mk/rt.mk index 6dcac0b95e8..de06d4917ee 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -35,7 +35,7 @@ # that's per-target so you're allowed to conditionally add files based on the # target. ################################################################################ -NATIVE_LIBS := rust_builtin hoedown uv_support morestack miniz context_switch \ +NATIVE_LIBS := rust_builtin hoedown morestack miniz context_switch \ rustrt_native rust_test_helpers # $(1) is the target triple @@ -50,7 +50,6 @@ NATIVE_DEPS_hoedown_$(1) := hoedown/src/autolink.c \ hoedown/src/html_smartypants.c \ hoedown/src/stack.c \ hoedown/src/version.c -NATIVE_DEPS_uv_support_$(1) := rust_uv.c NATIVE_DEPS_miniz_$(1) = miniz.c NATIVE_DEPS_rust_builtin_$(1) := rust_builtin.c \ rust_android_dummy.c diff --git a/src/rt/rust_uv.c b/src/rt/rust_uv.c deleted file mode 100644 index 0739e8b5e11..00000000000 --- a/src/rt/rust_uv.c +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#include -#include - -#ifdef __WIN32__ -// For alloca -#include -#endif - -#ifndef __WIN32__ -// for signal -#include -#endif - -#include "uv.h" - -void* -rust_uv_loop_new() { -// FIXME libuv doesn't always ignore SIGPIPE even though we don't need it. -#ifndef __WIN32__ - signal(SIGPIPE, SIG_IGN); -#endif - return (void*)uv_loop_new(); -} - -void -rust_uv_loop_set_data(uv_loop_t* loop, void* data) { - loop->data = data; -} - -uv_udp_t* -rust_uv_get_udp_handle_from_send_req(uv_udp_send_t* send_req) { - return send_req->handle; -} - -uv_stream_t* -rust_uv_get_stream_handle_from_connect_req(uv_connect_t* connect) { - return connect->handle; -} -uv_stream_t* -rust_uv_get_stream_handle_from_write_req(uv_write_t* write_req) { - return write_req->handle; -} - -uv_loop_t* -rust_uv_get_loop_for_uv_handle(uv_handle_t* handle) { - return handle->loop; -} - -void* -rust_uv_get_data_for_uv_loop(uv_loop_t* loop) { - return loop->data; -} - -void -rust_uv_set_data_for_uv_loop(uv_loop_t* loop, - void* data) { - loop->data = data; -} - -void* -rust_uv_get_data_for_uv_handle(uv_handle_t* handle) { - return handle->data; -} - -void -rust_uv_set_data_for_uv_handle(uv_handle_t* handle, void* data) { - handle->data = data; -} - -void* -rust_uv_get_data_for_req(uv_req_t* req) { - return req->data; -} - -void -rust_uv_set_data_for_req(uv_req_t* req, void* data) { - req->data = data; -} - -uintptr_t -rust_uv_handle_type_max() { - return UV_HANDLE_TYPE_MAX; -} - -uintptr_t -rust_uv_req_type_max() { - return UV_REQ_TYPE_MAX; -} - -ssize_t -rust_uv_get_result_from_fs_req(uv_fs_t* req) { - return req->result; -} -const char* -rust_uv_get_path_from_fs_req(uv_fs_t* req) { - return req->path; -} -void* -rust_uv_get_ptr_from_fs_req(uv_fs_t* req) { - return req->ptr; -} -uv_loop_t* -rust_uv_get_loop_from_fs_req(uv_fs_t* req) { - return req->loop; -} - -uv_loop_t* -rust_uv_get_loop_from_getaddrinfo_req(uv_getaddrinfo_t* req) { - return req->loop; -} - -void -rust_uv_populate_uv_stat(uv_fs_t* req_in, uv_stat_t* stat_out) { - stat_out->st_dev = req_in->statbuf.st_dev; - stat_out->st_mode = req_in->statbuf.st_mode; - stat_out->st_nlink = req_in->statbuf.st_nlink; - stat_out->st_uid = req_in->statbuf.st_uid; - stat_out->st_gid = req_in->statbuf.st_gid; - stat_out->st_rdev = req_in->statbuf.st_rdev; - stat_out->st_ino = req_in->statbuf.st_ino; - stat_out->st_size = req_in->statbuf.st_size; - stat_out->st_blksize = req_in->statbuf.st_blksize; - stat_out->st_blocks = req_in->statbuf.st_blocks; - stat_out->st_flags = req_in->statbuf.st_flags; - stat_out->st_gen = req_in->statbuf.st_gen; - stat_out->st_atim.tv_sec = req_in->statbuf.st_atim.tv_sec; - stat_out->st_atim.tv_nsec = req_in->statbuf.st_atim.tv_nsec; - stat_out->st_mtim.tv_sec = req_in->statbuf.st_mtim.tv_sec; - stat_out->st_mtim.tv_nsec = req_in->statbuf.st_mtim.tv_nsec; - stat_out->st_ctim.tv_sec = req_in->statbuf.st_ctim.tv_sec; - stat_out->st_ctim.tv_nsec = req_in->statbuf.st_ctim.tv_nsec; - stat_out->st_birthtim.tv_sec = req_in->statbuf.st_birthtim.tv_sec; - stat_out->st_birthtim.tv_nsec = req_in->statbuf.st_birthtim.tv_nsec; -} - -void -rust_set_stdio_container_flags(uv_stdio_container_t *c, int flags) { - c->flags = (uv_stdio_flags) flags; -} - -void -rust_set_stdio_container_fd(uv_stdio_container_t *c, int fd) { - c->data.fd = fd; -} - -void -rust_set_stdio_container_stream(uv_stdio_container_t *c, uv_stream_t *stream) { - c->data.stream = stream; -} - -int -rust_uv_process_pid(uv_process_t* p) { - return p->pid; -} - -int -rust_uv_guess_handle(int fd) { - return uv_guess_handle(fd); -} From 382f1bceb4e2a0496171f52d114a98ff8a86f9b7 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 00:08:07 +0300 Subject: [PATCH 17/43] core: remove raw::GcBox. --- src/liballoc/lib.rs | 1 - src/liballoc/util.rs | 30 ------------------------------ src/libcore/raw.rs | 9 --------- 3 files changed, 40 deletions(-) delete mode 100644 src/liballoc/util.rs diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 503c484e469..c31d746d8f2 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -92,7 +92,6 @@ pub use boxed as owned; pub mod heap; pub mod libc_heap; -pub mod util; // Primitive types using the heaps above diff --git a/src/liballoc/util.rs b/src/liballoc/util.rs deleted file mode 100644 index d5f0d25fb01..00000000000 --- a/src/liballoc/util.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![doc(hidden)] - -use core::mem; -use core::raw; - -#[inline] -#[deprecated] -pub fn get_box_size(body_size: uint, body_align: uint) -> uint { - let header_size = mem::size_of::>(); - let total_size = align_to(header_size, body_align) + body_size; - total_size -} - -// Rounds size to the next alignment. Alignment is required to be a power of -// two. -#[inline] -fn align_to(size: uint, align: uint) -> uint { - assert!(align != 0); - (size + align - 1) & !(align - 1) -} diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 86b96ff15f1..a62e2ecdca0 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -20,15 +20,6 @@ use mem; -/// The representation of `std::gc::Gc`. -pub struct GcBox { - pub ref_count: uint, - pub drop_glue: fn(ptr: *mut u8), - pub prev: *mut GcBox, - pub next: *mut GcBox, - pub data: T, -} - /// The representation of a Rust slice pub struct Slice { pub data: *const T, From 2487e164aeeeedaba78f597724a137959b1fb299 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 00:09:46 +0300 Subject: [PATCH 18/43] rustrt: remove local_heap implementation. --- src/librustrt/lib.rs | 6 +- src/librustrt/local_heap.rs | 345 ------------------------------------ src/librustrt/task.rs | 41 +---- 3 files changed, 11 insertions(+), 381 deletions(-) delete mode 100644 src/librustrt/local_heap.rs diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index 1183b14fb4e..ad1eac41e4d 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -58,7 +58,6 @@ pub mod c_str; pub mod exclusive; pub mod local; pub mod local_data; -pub mod local_heap; pub mod mutex; pub mod rtio; pub mod stack; @@ -105,9 +104,8 @@ pub static DEFAULT_ERROR_CODE: int = 101; /// One-time runtime initialization. /// -/// Initializes global state, including frobbing -/// the crate's logging flags, registering GC -/// metadata, and storing the process arguments. +/// Initializes global state, including frobbing the crate's logging flags, +/// and storing the process arguments. pub fn init(argc: int, argv: *const *const u8) { // FIXME: Derefing these pointers is not safe. // Need to propagate the unsafety to `start`. diff --git a/src/librustrt/local_heap.rs b/src/librustrt/local_heap.rs deleted file mode 100644 index 0e84e9c0097..00000000000 --- a/src/librustrt/local_heap.rs +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The local, garbage collected heap - -use core::prelude::*; - -use alloc::libc_heap; -use alloc::util; -use libc::{c_void, free}; - -use core::mem; -use core::ptr; -use core::raw; -use local::Local; -use task::Task; - -static RC_IMMORTAL : uint = 0x77777777; - -pub type Box = raw::GcBox<()>; - -pub struct MemoryRegion { - live_allocations: uint, -} - -pub struct LocalHeap { - memory_region: MemoryRegion, - live_allocs: *mut raw::GcBox<()>, -} - -impl LocalHeap { - pub fn new() -> LocalHeap { - LocalHeap { - memory_region: MemoryRegion { live_allocations: 0 }, - live_allocs: ptr::null_mut(), - } - } - - #[inline] - #[allow(deprecated)] - pub fn alloc(&mut self, - drop_glue: fn(*mut u8), - size: uint, - align: uint) -> *mut Box { - let total_size = util::get_box_size(size, align); - let alloc = self.memory_region.malloc(total_size); - { - // Make sure that we can't use `mybox` outside of this scope - let mybox: &mut Box = unsafe { mem::transmute(alloc) }; - // Clear out this box, and move it to the front of the live - // allocations list - mybox.drop_glue = drop_glue; - mybox.ref_count = 1; - mybox.prev = ptr::null_mut(); - mybox.next = self.live_allocs; - if !self.live_allocs.is_null() { - unsafe { (*self.live_allocs).prev = alloc; } - } - self.live_allocs = alloc; - } - return alloc; - } - - #[inline] - pub fn realloc(&mut self, ptr: *mut Box, size: uint) -> *mut Box { - // Make sure that we can't use `mybox` outside of this scope - let total_size = size + mem::size_of::(); - let new_box = self.memory_region.realloc(ptr, total_size); - { - // Fix links because we could have moved around - let mybox: &mut Box = unsafe { mem::transmute(new_box) }; - if !mybox.prev.is_null() { - unsafe { (*mybox.prev).next = new_box; } - } - if !mybox.next.is_null() { - unsafe { (*mybox.next).prev = new_box; } - } - } - if self.live_allocs == ptr { - self.live_allocs = new_box; - } - return new_box; - } - - #[inline] - pub fn free(&mut self, alloc: *mut Box) { - { - // Make sure that we can't use `mybox` outside of this scope - let mybox: &mut Box = unsafe { mem::transmute(alloc) }; - - // Unlink it from the linked list - if !mybox.prev.is_null() { - unsafe { (*mybox.prev).next = mybox.next; } - } - if !mybox.next.is_null() { - unsafe { (*mybox.next).prev = mybox.prev; } - } - if self.live_allocs == alloc { - self.live_allocs = mybox.next; - } - } - - self.memory_region.free(alloc); - } - - /// Immortalize all pending allocations, forcing them to live forever. - /// - /// This function will freeze all allocations to prevent all pending - /// allocations from being deallocated. This is used in preparation for when - /// a task is about to destroy TLD. - pub unsafe fn immortalize(&mut self) { - let mut n_total_boxes = 0u; - - // Pass 1: Make all boxes immortal. - // - // In this pass, nothing gets freed, so it does not matter whether - // we read the next field before or after the callback. - self.each_live_alloc(true, |_, alloc| { - n_total_boxes += 1; - (*alloc).ref_count = RC_IMMORTAL; - }); - - if debug_mem() { - // We do logging here w/o allocation. - rterrln!("total boxes annihilated: {}", n_total_boxes); - } - } - - /// Continues deallocation of the all pending allocations in this arena. - /// - /// This is invoked from the destructor, and requires that `immortalize` has - /// been called previously. - unsafe fn annihilate(&mut self) { - // Pass 2: Drop all boxes. - // - // In this pass, unique-managed boxes may get freed, but not - // managed boxes, so we must read the `next` field *after* the - // callback, as the original value may have been freed. - self.each_live_alloc(false, |_, alloc| { - let drop_glue = (*alloc).drop_glue; - let data = &mut (*alloc).data as *mut (); - drop_glue(data as *mut u8); - }); - - // Pass 3: Free all boxes. - // - // In this pass, managed boxes may get freed (but not - // unique-managed boxes, though I think that none of those are - // left), so we must read the `next` field before, since it will - // not be valid after. - self.each_live_alloc(true, |me, alloc| { - me.free(alloc); - }); - } - - unsafe fn each_live_alloc(&mut self, read_next_before: bool, - f: |&mut LocalHeap, alloc: *mut raw::GcBox<()>|) { - //! Walks the internal list of allocations - - let mut alloc = self.live_allocs; - while alloc != ptr::null_mut() { - let next_before = (*alloc).next; - - f(self, alloc); - - if read_next_before { - alloc = next_before; - } else { - alloc = (*alloc).next; - } - } - } -} - -impl Drop for LocalHeap { - fn drop(&mut self) { - unsafe { self.annihilate() } - assert!(self.live_allocs.is_null()); - } -} - -struct AllocHeader; - -impl AllocHeader { - fn init(&mut self, _size: u32) {} - fn assert_sane(&self) {} - fn update_size(&mut self, _size: u32) {} - - fn as_box(&mut self) -> *mut Box { - let myaddr: uint = unsafe { mem::transmute(self) }; - (myaddr + AllocHeader::size()) as *mut Box - } - - fn size() -> uint { - // For some platforms, 16 byte alignment is required. - let ptr_size = 16; - let header_size = mem::size_of::(); - return (header_size + ptr_size - 1) / ptr_size * ptr_size; - } - - fn from(a_box: *mut Box) -> *mut AllocHeader { - (a_box as uint - AllocHeader::size()) as *mut AllocHeader - } -} - -#[cfg(unix)] -fn debug_mem() -> bool { - // FIXME: Need to port the environment struct to newsched - false -} - -#[cfg(windows)] -fn debug_mem() -> bool { - false -} - -impl MemoryRegion { - #[inline] - fn malloc(&mut self, size: uint) -> *mut Box { - let total_size = size + AllocHeader::size(); - let alloc: *mut AllocHeader = unsafe { - libc_heap::malloc_raw(total_size) as *mut AllocHeader - }; - - let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) }; - alloc.init(size as u32); - self.claim(alloc); - self.live_allocations += 1; - - return alloc.as_box(); - } - - #[inline] - fn realloc(&mut self, alloc: *mut Box, size: uint) -> *mut Box { - rtassert!(!alloc.is_null()); - let orig_alloc = AllocHeader::from(alloc); - unsafe { (*orig_alloc).assert_sane(); } - - let total_size = size + AllocHeader::size(); - let alloc: *mut AllocHeader = unsafe { - libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *mut AllocHeader - }; - - let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) }; - alloc.assert_sane(); - alloc.update_size(size as u32); - self.update(alloc, orig_alloc as *mut AllocHeader); - return alloc.as_box(); - } - - #[inline] - fn free(&mut self, alloc: *mut Box) { - rtassert!(!alloc.is_null()); - let alloc = AllocHeader::from(alloc); - unsafe { - (*alloc).assert_sane(); - self.release(mem::transmute(alloc)); - rtassert!(self.live_allocations > 0); - self.live_allocations -= 1; - free(alloc as *mut c_void) - } - } - - #[inline] - fn claim(&mut self, _alloc: &mut AllocHeader) {} - #[inline] - fn release(&mut self, _alloc: &AllocHeader) {} - #[inline] - fn update(&mut self, _alloc: &mut AllocHeader, _orig: *mut AllocHeader) {} -} - -impl Drop for MemoryRegion { - fn drop(&mut self) { - if self.live_allocations != 0 { - rtabort!("leaked managed memory ({} objects)", self.live_allocations); - } - } -} - -#[cfg(not(test))] -#[lang="malloc"] -#[inline] -pub unsafe fn local_malloc_(drop_glue: fn(*mut u8), size: uint, - align: uint) -> *mut u8 { - local_malloc(drop_glue, size, align) -} - -#[inline] -pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, - align: uint) -> *mut u8 { - // FIXME: Unsafe borrow for speed. Lame. - let task: Option<*mut Task> = Local::try_unsafe_borrow(); - match task { - Some(task) => { - (*task).heap.alloc(drop_glue, size, align) as *mut u8 - } - None => rtabort!("local malloc outside of task") - } -} - -#[cfg(not(test))] -#[lang="free"] -#[inline] -pub unsafe fn local_free_(ptr: *mut u8) { - local_free(ptr) -} - -// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from -// inside a landing pad may corrupt the state of the exception handler. If a -// problem occurs, call exit instead. -#[inline] -pub unsafe fn local_free(ptr: *mut u8) { - // FIXME: Unsafe borrow for speed. Lame. - let task_ptr: Option<*mut Task> = Local::try_unsafe_borrow(); - match task_ptr { - Some(task) => { - (*task).heap.free(ptr as *mut Box) - } - None => rtabort!("local free outside of task") - } -} - -#[cfg(test)] -mod bench { - extern crate test; - use self::test::Bencher; - use std::gc::GC; - - #[bench] - fn alloc_managed_small(b: &mut Bencher) { - b.iter(|| { box(GC) 10i }); - } - - #[bench] - fn alloc_managed_big(b: &mut Bencher) { - b.iter(|| { box(GC) ([10i, ..1000]) }); - } -} diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index 3d42b91fef1..9e88d05884c 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -9,9 +9,8 @@ // except according to those terms. //! Language-level runtime services that should reasonably expected -//! to be available 'everywhere'. Local heaps, GC, unwinding, -//! local storage, and logging. Even a 'freestanding' Rust would likely want -//! to implement this. +//! to be available 'everywhere'. Unwinding, local storage, and logging. +//! Even a 'freestanding' Rust would likely want to implement this. use alloc::arc::Arc; use alloc::boxed::{BoxAny, Box}; @@ -27,7 +26,6 @@ use core::raw; use local_data; use Runtime; use local::Local; -use local_heap::LocalHeap; use rtio::LocalIo; use unwind; use unwind::Unwinder; @@ -95,8 +93,6 @@ use collections::str::SendStr; /// # } /// ``` pub struct Task { - pub heap: LocalHeap, - pub gc: GarbageCollector, pub storage: LocalStorage, pub unwinder: Unwinder, pub death: Death, @@ -132,7 +128,6 @@ pub struct TaskOpts { /// children tasks complete, recommend using a result future. pub type Result = ::core::result::Result<(), Box>; -pub struct GarbageCollector; pub struct LocalStorage(pub Option); /// A handle to a blocked task. Usually this means having the Box @@ -163,8 +158,6 @@ impl Task { /// task creation functions through libnative or libgreen. pub fn new() -> Task { Task { - heap: LocalHeap::new(), - gc: GarbageCollector, storage: LocalStorage(None), unwinder: Unwinder::new(), death: Death::new(), @@ -264,32 +257,22 @@ impl Task { /// already been destroyed and/or annihilated. fn cleanup(self: Box, result: Result) -> Box { // The first thing to do when cleaning up is to deallocate our local - // resources, such as TLD and GC data. + // resources, such as TLD. // // FIXME: there are a number of problems with this code // // 1. If any TLD object fails destruction, then all of TLD will leak. // This appears to be a consequence of #14875. // - // 2. Failing during GC annihilation aborts the runtime #14876. + // 2. Setting a TLD key while destroying TLD will abort the runtime #14807. // - // 3. Setting a TLD key while destroying TLD or while destroying GC will - // abort the runtime #14807. - // - // 4. Invoking GC in GC destructors will abort the runtime #6996. - // - // 5. The order of destruction of TLD and GC matters, but either way is - // susceptible to leaks (see 3/4) #8302. + // 3. The order of destruction of TLD matters, but either way is + // susceptible to leaks (see 2) #8302. // // That being said, there are a few upshots to this code // // 1. If TLD destruction fails, heap destruction will be attempted. - // There is a test for this at fail-during-tld-destroy.rs. Sadly the - // other way can't be tested due to point 2 above. Note that we must - // immortalize the heap first because if any deallocations are - // attempted while TLD is being dropped it will attempt to free the - // allocation from the wrong heap (because the current one has been - // replaced). + // There is a test for this at fail-during-tld-destroy.rs. // // 2. One failure in destruction is tolerable, so long as the task // didn't originally fail while it was running. @@ -301,15 +284,10 @@ impl Task { let &LocalStorage(ref mut optmap) = &mut task.storage; optmap.take() }; - let mut heap = mem::replace(&mut task.heap, LocalHeap::new()); - unsafe { heap.immortalize() } drop(task); // First, destroy task-local storage. This may run user dtors. drop(tld); - - // Destroy remaining boxes. Also may run user dtors. - drop(heap); }); // If the above `run` block failed, then it must be the case that the @@ -327,9 +305,8 @@ impl Task { Local::put(task); // FIXME: this is running in a seriously constrained context. If this - // allocates GC or allocates TLD then it will likely abort the - // runtime. Similarly, if this fails, this will also likely abort - // the runtime. + // allocates TLD then it will likely abort the runtime. Similarly, + // if this fails, this will also likely abort the runtime. // // This closure is currently limited to a channel send via the // standard library's task interface, but this needs From d07cd175daa24e25ce287ae013e5b6691c39dc36 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 00:00:59 +0300 Subject: [PATCH 19/43] std: remove gc module. --- src/libstd/gc.rs | 156 ---------------------------------------------- src/libstd/lib.rs | 4 -- 2 files changed, 160 deletions(-) delete mode 100644 src/libstd/gc.rs diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs deleted file mode 100644 index ecef8e9ed90..00000000000 --- a/src/libstd/gc.rs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! Task-local garbage-collected boxes - -The `Gc` type provides shared ownership of an immutable value. Destruction is not deterministic, and -will occur some time between every `Gc` handle being gone and the end of the task. The garbage -collector is task-local so `Gc` is not sendable. - -*/ - -#![experimental] -#![allow(experimental)] - -use clone::Clone; -use cmp::{Ord, PartialOrd, Ordering, Eq, PartialEq}; -use default::Default; -use fmt; -use hash; -use kinds::marker; -use option::Option; -use ops::Deref; -use raw; - -/// Immutable garbage-collected pointer type -#[lang="gc"] -#[experimental = "Gc is currently based on reference-counting and will not collect cycles until \ - task annihilation. For now, cycles need to be broken manually by using `Rc` \ - with a non-owning `Weak` pointer. A tracing garbage collector is planned."] -pub struct Gc { - _ptr: *mut T, - marker: marker::NoSend, -} - -#[unstable] -impl Clone for Gc { - /// Clone the pointer only - #[inline] - fn clone(&self) -> Gc { *self } -} - -/// An value that represents the task-local managed heap. -/// -/// Use this like `let foo = box(GC) Bar::new(...);` -#[lang="managed_heap"] -#[cfg(not(test))] -pub static GC: () = (); - -impl PartialEq for Gc { - #[inline] - fn eq(&self, other: &Gc) -> bool { *(*self) == *(*other) } - #[inline] - fn ne(&self, other: &Gc) -> bool { *(*self) != *(*other) } -} -impl PartialOrd for Gc { - #[inline] - fn partial_cmp(&self, other: &Gc) -> Option { - (**self).partial_cmp(&**other) - } - #[inline] - fn lt(&self, other: &Gc) -> bool { *(*self) < *(*other) } - #[inline] - fn le(&self, other: &Gc) -> bool { *(*self) <= *(*other) } - #[inline] - fn ge(&self, other: &Gc) -> bool { *(*self) >= *(*other) } - #[inline] - fn gt(&self, other: &Gc) -> bool { *(*self) > *(*other) } -} -impl Ord for Gc { - #[inline] - fn cmp(&self, other: &Gc) -> Ordering { (**self).cmp(&**other) } -} -impl Eq for Gc {} - -impl Deref for Gc { - fn deref<'a>(&'a self) -> &'a T { &**self } -} - -impl Default for Gc { - fn default() -> Gc { - box(GC) Default::default() - } -} - -impl raw::Repr<*const raw::GcBox> for Gc {} - -impl + 'static> hash::Hash for Gc { - fn hash(&self, s: &mut S) { - (**self).hash(s) - } -} - -impl fmt::Show for Gc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - (**self).fmt(f) - } -} - -#[cfg(test)] -mod tests { - use prelude::*; - use super::*; - use cell::RefCell; - - #[test] - fn test_managed_clone() { - let a = box(GC) 5i; - let b: Gc = a.clone(); - assert!(a == b); - } - - #[test] - fn test_clone() { - let x = Gc::new(RefCell::new(5)); - let y = x.clone(); - *x.borrow().borrow_mut() = 20; - assert_eq!(*y.borrow().borrow(), 20); - } - - #[test] - fn test_simple() { - let x = Gc::new(5); - assert_eq!(*x.borrow(), 5); - } - - #[test] - fn test_simple_clone() { - let x = Gc::new(5); - let y = x.clone(); - assert_eq!(*x.borrow(), 5); - assert_eq!(*y.borrow(), 5); - } - - #[test] - fn test_ptr_eq() { - let x = Gc::new(5); - let y = x.clone(); - let z = Gc::new(7); - assert!(x.ptr_eq(&x)); - assert!(x.ptr_eq(&y)); - assert!(!x.ptr_eq(&z)); - } - - #[test] - fn test_destructor() { - let x = Gc::new(box 5); - assert_eq!(**x.borrow(), 5); - } -} diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 82de55efad6..f6c37b6cfc3 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -137,7 +137,6 @@ extern crate rustrt; #[cfg(test)] pub use realstd::cmp; #[cfg(test)] pub use realstd::ty; #[cfg(test)] pub use realstd::boxed; -#[cfg(test)] pub use realstd::gc; // NB: These reexports are in the order they should be listed in rustdoc @@ -220,9 +219,6 @@ pub mod rand; pub mod ascii; -#[cfg(not(test))] -pub mod gc; - pub mod time; /* Common traits */ From 8b1d3e6c1c0a7d24d1c77b567e5fad6e1be6baca Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 00:10:40 +0300 Subject: [PATCH 20/43] serialize: remove proxy impls for Gc. --- src/libserialize/serialize.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index d005a8ef004..3bed4e4040b 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -16,7 +16,6 @@ Core encoding and decoding interfaces. use std::path; use std::rc::Rc; -use std::gc::{Gc, GC}; use std::cell::{Cell, RefCell}; pub trait Encoder { @@ -392,12 +391,6 @@ impl,T:Decodable> Decodable for Box { } } -impl,T:'static + Encodable> Encodable for Gc { - fn encode(&self, s: &mut S) -> Result<(), E> { - (**self).encode(s) - } -} - impl,T:Encodable> Encodable for Rc { #[inline] fn encode(&self, s: &mut S) -> Result<(), E> { @@ -412,12 +405,6 @@ impl,T:Decodable> Decodable for Rc { } } -impl,T:Decodable + 'static> Decodable for Gc { - fn decode(d: &mut D) -> Result, E> { - Ok(box(GC) try!(Decodable::decode(d))) - } -} - impl<'a, E, S:Encoder,T:Encodable> Encodable for &'a [T] { fn encode(&self, s: &mut S) -> Result<(), E> { s.emit_seq(self.len(), |s| { From fb58109070f96766cbc0d74fef6e66892a787321 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 00:16:38 +0300 Subject: [PATCH 21/43] debug: remove Gc support from Repr. --- src/libdebug/reflect.rs | 5 ++--- src/libdebug/repr.rs | 10 +++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/libdebug/reflect.rs b/src/libdebug/reflect.rs index 80d0f8a8794..1e771a2b40a 100644 --- a/src/libdebug/reflect.rs +++ b/src/libdebug/reflect.rs @@ -18,7 +18,6 @@ Runtime type reflection use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor}; use std::mem; -use std::gc::Gc; /** * Trait for visitor that wishes to reflect on data. @@ -194,9 +193,9 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::>(); + self.align_to::>(); if ! self.inner.visit_box(mtbl, inner) { return false; } - self.bump_past::>(); + self.bump_past::>(); true } diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs index 5fbba286fea..98c01000cb0 100644 --- a/src/libdebug/repr.rs +++ b/src/libdebug/repr.rs @@ -274,13 +274,9 @@ impl<'a> TyVisitor for ReprVisitor<'a> { self.get::<&str>(|this, s| this.write_escaped_slice(*s)) } - fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - try!(self, self.writer.write("box(GC) ".as_bytes())); - self.write_mut_qualifier(mtbl); - self.get::<&raw::GcBox<()>>(|this, b| { - let p = &b.data as *const () as *const u8; - this.visit_ptr_inner(p, inner) - }) + fn visit_box(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { + try!(self, self.writer.write("box(GC) ???".as_bytes())); + true } fn visit_uniq(&mut self, _mtbl: uint, inner: *const TyDesc) -> bool { From a99e626d07b62cfea5711f018b1497f8bdc04e90 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 30 Sep 2014 23:58:34 +0300 Subject: [PATCH 22/43] syntax: remove unused imports of Gc and GC. --- src/libsyntax/test.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 828a6124aa0..00fdf436636 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -13,7 +13,6 @@ #![allow(dead_code)] #![allow(unused_imports)] -use std::gc::{Gc, GC}; use std::slice; use std::mem; use std::vec; From d1a57e479c13804e1cda5658f482e840c3a1cd79 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 00:59:56 +0300 Subject: [PATCH 23/43] syntax: ast: remove TyBox and UnBox. --- src/librustc/lint/builtin.rs | 2 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_static.rs | 4 ---- src/librustc/middle/trans/consts.rs | 2 +- src/librustc/middle/trans/expr.rs | 3 --- src/librustc/middle/typeck/astconv.rs | 4 ---- src/librustc/middle/typeck/check/mod.rs | 9 ++------- src/librustc/middle/typeck/check/regionck.rs | 8 -------- src/librustc/middle/typeck/infer/error_reporting.rs | 2 -- src/librustdoc/clean/mod.rs | 1 - src/libsyntax/ast.rs | 2 -- src/libsyntax/ast_util.rs | 1 - src/libsyntax/ext/build.rs | 5 ----- src/libsyntax/feature_gate.rs | 12 ------------ src/libsyntax/fold.rs | 1 - src/libsyntax/parse/parser.rs | 9 ++++----- src/libsyntax/print/pprust.rs | 4 ---- src/libsyntax/visit.rs | 2 +- 18 files changed, 10 insertions(+), 63 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 277ecfc686b..5774a0485cb 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -1289,7 +1289,7 @@ impl LintPass for UnnecessaryAllocation { fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { match e.node { - ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (), + ast::ExprUnary(ast::UnUniq, _) => (), _ => return } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index cc3679ec31d..ba721acb231 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -100,7 +100,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) { if v.in_const { match e.node { ExprUnary(UnDeref, _) => { } - ExprUnary(UnBox, _) | ExprUnary(UnUniq, _) => { + ExprUnary(UnUniq, _) => { span_err!(v.tcx.sess, e.span, E0010, "cannot do allocations in constant expressions"); return; } diff --git a/src/librustc/middle/check_static.rs b/src/librustc/middle/check_static.rs index 7a11090a8ee..64e4d7ff284 100644 --- a/src/librustc/middle/check_static.rs +++ b/src/librustc/middle/check_static.rs @@ -115,10 +115,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> { span_err!(self.tcx.sess, e.span, E0020, "static items are not allowed to have mutable slices"); }, - ast::ExprUnary(ast::UnBox, _) => { - span_err!(self.tcx.sess, e.span, E0021, - "static items are not allowed to have managed pointers"); - } ast::ExprBox(..) | ast::ExprUnary(ast::UnUniq, _) => { span_err!(self.tcx.sess, e.span, E0022, diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index c499fcf4bf8..196efd7d2cc 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -421,7 +421,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, let ty = ty::expr_ty(cx.tcx(), &**e); let is_float = ty::type_is_fp(ty); return (match u { - ast::UnBox | ast::UnUniq | ast::UnDeref => { + ast::UnUniq | ast::UnDeref => { let (dv, _dt) = const_deref(cx, te, ty, true); dv } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 37a39ef8e3b..0b47544c562 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -1533,9 +1533,6 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, }; immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock() } - ast::UnBox => { - trans_managed_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr)) - } ast::UnUniq => { trans_uniq_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr)) } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index b73fa172d3f..72c3c1715e0 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -856,10 +856,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( match ast_ty.node { ast::TyNil => ty::mk_nil(), ast::TyBot => ty::mk_bot(), - ast::TyBox(ref ty) => { - mk_pointer(this, rscope, ast::MutImmutable, &**ty, Box, - |ty| ty::mk_box(tcx, ty)) - } ast::TyUniq(ref ty) => { mk_pointer(this, rscope, ast::MutImmutable, &**ty, Uniq, |ty| ty::mk_uniq(tcx, ty)) diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 5f7f77ea7da..d8b5185a47a 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3881,8 +3881,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt, ast::ExprUnary(unop, ref oprnd) => { let expected_inner = expected.map(fcx, |sty| { match unop { - ast::UnBox | ast::UnUniq => match *sty { - ty::ty_box(ty) | ty::ty_uniq(ty) => { + ast::UnUniq => match *sty { + ty::ty_uniq(ty) => { ExpectHasType(ty) } _ => { @@ -3907,11 +3907,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt, if !ty::type_is_error(oprnd_t) { match unop { - ast::UnBox => { - if !ty::type_is_bot(oprnd_t) { - oprnd_t = ty::mk_box(tcx, oprnd_t) - } - } ast::UnUniq => { if !ty::type_is_bot(oprnd_t) { oprnd_t = ty::mk_uniq(tcx, oprnd_t); diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 9e20028569b..53edcb303f7 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -663,14 +663,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { visit::walk_expr(rcx, expr); } - ast::ExprUnary(ast::UnBox, ref base) => { - // Managed data must not have borrowed pointers within it: - let base_ty = rcx.resolve_node_type(base.id); - type_must_outlive(rcx, infer::Managed(expr.span), - base_ty, ty::ReStatic); - visit::walk_expr(rcx, expr); - } - ast::ExprUnary(ast::UnDeref, ref base) => { // For *a, the lifetime of a must enclose the deref let method_call = MethodCall::expr(expr.id); diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 2ad6a1f72e2..0149220fde4 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -1285,7 +1285,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { ast::TyPtr(ref mut_ty) => { ty_queue.push(&*mut_ty.ty); } - ast::TyBox(ref ty) | ast::TyVec(ref ty) | ast::TyUniq(ref ty) | ast::TyFixedLengthVec(ref ty, _) => { @@ -1323,7 +1322,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { ty: build_to(mut_ty.ty, to), }) } - ast::TyBox(ty) => ast::TyBox(build_to(ty, to)), ast::TyVec(ty) => ast::TyVec(build_to(ty, to)), ast::TyUniq(ty) => ast::TyUniq(build_to(ty, to)), ast::TyFixedLengthVec(ty, e) => { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0b04536f054..cb5c633bd25 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1215,7 +1215,6 @@ impl Clean for ast::Ty { TyRptr(ref l, ref m) => BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx), type_: box m.ty.clean(cx)}, - TyBox(ref ty) => Managed(box ty.clean(cx)), TyUniq(ref ty) => Unique(box ty.clean(cx)), TyVec(ref ty) => Vector(box ty.clean(cx)), TyFixedLengthVec(ref ty, ref e) => FixedVector(box ty.clean(cx), diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 59c824d0eae..0a87c0a344e 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -416,7 +416,6 @@ pub enum BinOp { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum UnOp { - UnBox, UnUniq, UnDeref, UnNot, @@ -953,7 +952,6 @@ pub struct UnboxedFnTy { pub enum Ty_ { TyNil, TyBot, /* bottom type */ - TyBox(P), TyUniq(P), TyVec(P), TyFixedLengthVec(P, P), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 6d61c851476..31860062580 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -90,7 +90,6 @@ pub fn is_shift_binop(b: BinOp) -> bool { pub fn unop_to_string(op: UnOp) -> &'static str { match op { - UnBox => "box(GC) ", UnUniq => "box() ", UnDeref => "*", UnNot => "!", diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f2b806f43cc..1fdb6dd505f 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -112,7 +112,6 @@ pub trait AstBuilder { fn expr_deref(&self, sp: Span, e: P) -> P; fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P) -> P; - fn expr_managed(&self, sp: Span, e: P) -> P; fn expr_addr_of(&self, sp: Span, e: P) -> P; fn expr_mut_addr_of(&self, sp: Span, e: P) -> P; fn expr_field_access(&self, span: Span, expr: P, ident: ast::Ident) -> P; @@ -565,10 +564,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(sp, ast::ExprUnary(op, e)) } - fn expr_managed(&self, sp: Span, e: P) -> P { - self.expr_unary(sp, ast::UnBox, e) - } - fn expr_field_access(&self, sp: Span, expr: P, ident: ast::Ident) -> P { let field_name = token::get_ident(ident); let field_span = Span { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 38de2a9c284..8565bebe269 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -136,14 +136,6 @@ impl<'a> Context<'a> { } } - fn gate_box(&self, span: Span) { - self.gate_feature("managed_boxes", span, - "The managed box syntax is being replaced by the \ - `std::gc::Gc` and `std::rc::Rc` types. Equivalent \ - functionality to managed trait objects will be \ - implemented but is currently missing."); - } - fn has_feature(&self, feature: &str) -> bool { self.features.iter().any(|n| n.as_slice() == feature) } @@ -331,7 +323,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { experimental and likely to be removed"); }, - ast::TyBox(_) => { self.gate_box(t.span); } ast::TyUnboxedFn(..) => { self.gate_feature("unboxed_closure_sugar", t.span, @@ -345,9 +336,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { fn visit_expr(&mut self, e: &ast::Expr) { match e.node { - ast::ExprUnary(ast::UnBox, _) => { - self.gate_box(e.span); - } ast::ExprUnboxedFn(..) => { self.gate_feature("unboxed_closures", e.span, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 31bec58a4da..84de6c3b913 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -372,7 +372,6 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { id: fld.new_id(id), node: match node { TyNil | TyBot | TyInfer => node, - TyBox(ty) => TyBox(fld.fold_ty(ty)), TyUniq(ty) => TyUniq(fld.fold_ty(ty)), TyVec(ty) => TyVec(fld.fold_ty(ty)), TyPtr(mt) => TyPtr(fld.fold_mt(mt)), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c8f1b7f9a8e..8082fd65f1a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -16,8 +16,7 @@ use ast::{RegionTyParamBound, TraitTyParamBound}; use ast::{ProvidedMethod, Public, FnStyle}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, Block}; -use ast::{BlockCheckMode, UnBox}; -use ast::{CaptureByRef, CaptureByValue, CaptureClause}; +use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause}; use ast::{Crate, CrateConfig, Decl, DeclItem}; use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; @@ -50,7 +49,7 @@ use ast::{StructVariantKind, BiSub}; use ast::StrStyle; use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{TokenTree, TraitItem, TraitRef, TTDelim, TTSeq, TTTok}; -use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox}; +use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot}; use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn}; use ast::{TyTypeof, TyInfer, TypeMethod}; use ast::{TyNil, TyParam, TyParamBound, TyParen, TyPath, TyPtr, TyQPath}; @@ -1455,7 +1454,7 @@ impl<'a> Parser<'a> { self.bump(); let span = self.last_span; self.obsolete(span, ObsoleteManagedType); - TyBox(self.parse_ty(plus_allowed)) + TyUniq(self.parse_ty(plus_allowed)) } else if self.token == token::TILDE { // OWNED POINTER self.bump(); @@ -2729,7 +2728,7 @@ impl<'a> Parser<'a> { self.obsolete(span, ObsoleteManagedExpr); let e = self.parse_prefix_expr(); hi = e.span.hi; - ex = self.mk_unary(UnBox, e); + ex = self.mk_unary(UnUniq, e); } token::TILDE => { self.bump(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a8e99b4e85f..8400d9aea3b 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -546,10 +546,6 @@ impl<'a> State<'a> { match ty.node { ast::TyNil => try!(word(&mut self.s, "()")), ast::TyBot => try!(word(&mut self.s, "!")), - ast::TyBox(ref ty) => { - try!(word(&mut self.s, "@")); - try!(self.print_type(&**ty)); - } ast::TyUniq(ref ty) => { try!(word(&mut self.s, "~")); try!(self.print_type(&**ty)); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 6fc79e2c42a..249f87d3102 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -326,7 +326,7 @@ pub fn skip_ty<'v, V: Visitor<'v>>(_: &mut V, _: &'v Ty) { pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { match typ.node { - TyUniq(ref ty) | TyVec(ref ty) | TyBox(ref ty) | TyParen(ref ty) => { + TyUniq(ref ty) | TyVec(ref ty) | TyParen(ref ty) => { visitor.visit_ty(&**ty) } TyPtr(ref mutable_type) => { From 8a91d33ee7267c71a0ae286739dbd72433470004 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 01:26:04 +0300 Subject: [PATCH 24/43] rustc: remove support for Gc. --- src/librustc/lint/builtin.rs | 20 +-- src/librustc/metadata/tydecode.rs | 1 - src/librustc/metadata/tyencode.rs | 1 - src/librustc/middle/borrowck/check_loans.rs | 5 - .../borrowck/gather_loans/gather_moves.rs | 1 - .../middle/borrowck/gather_loans/lifetime.rs | 4 +- .../borrowck/gather_loans/move_error.rs | 1 - .../borrowck/gather_loans/restrictions.rs | 5 +- src/librustc/middle/borrowck/mod.rs | 5 - src/librustc/middle/check_match.rs | 7 +- src/librustc/middle/intrinsicck.rs | 4 +- src/librustc/middle/lang_items.rs | 4 - src/librustc/middle/mem_categorization.rs | 17 +-- src/librustc/middle/traits/coherence.rs | 5 - src/librustc/middle/traits/select.rs | 17 --- src/librustc/middle/trans/adt.rs | 3 - src/librustc/middle/trans/base.rs | 30 ----- src/librustc/middle/trans/cleanup.rs | 7 - src/librustc/middle/trans/common.rs | 2 +- src/librustc/middle/trans/datum.rs | 44 +++--- src/librustc/middle/trans/debuginfo.rs | 126 +----------------- src/librustc/middle/trans/doc.rs | 2 +- src/librustc/middle/trans/expr.rs | 41 +----- src/librustc/middle/trans/glue.rs | 70 +--------- src/librustc/middle/trans/reflect.rs | 8 -- src/librustc/middle/trans/tvec.rs | 2 +- src/librustc/middle/trans/type_of.rs | 4 - src/librustc/middle/ty.rs | 74 +++------- src/librustc/middle/ty_fold.rs | 3 - src/librustc/middle/typeck/astconv.rs | 60 --------- src/librustc/middle/typeck/check/method.rs | 2 +- src/librustc/middle/typeck/check/mod.rs | 6 - src/librustc/middle/typeck/check/regionck.rs | 3 - .../middle/typeck/check/regionmanip.rs | 1 - src/librustc/middle/typeck/check/vtable2.rs | 2 +- src/librustc/middle/typeck/coherence/mod.rs | 6 +- src/librustc/middle/typeck/infer/coercion.rs | 2 +- src/librustc/middle/typeck/infer/combine.rs | 4 - .../middle/typeck/infer/error_reporting.rs | 10 -- src/librustc/middle/typeck/infer/mod.rs | 5 - src/librustc/middle/typeck/infer/skolemize.rs | 1 - src/librustc/middle/typeck/variance.rs | 2 +- src/librustc/util/ppaux.rs | 3 +- 43 files changed, 55 insertions(+), 565 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 5774a0485cb..213e8b44813 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -412,26 +412,16 @@ impl LintPass for CTypes { } } -declare_lint!(MANAGED_HEAP_MEMORY, Allow, - "use of managed (@ type) heap memory") - declare_lint!(OWNED_HEAP_MEMORY, Allow, "use of owned (Box type) heap memory") -declare_lint!(HEAP_MEMORY, Allow, - "use of any (Box type or @ type) heap memory") - pub struct HeapMemory; impl HeapMemory { fn check_heap_type(&self, cx: &Context, span: Span, ty: ty::t) { - let mut n_box = 0i; let mut n_uniq = 0i; ty::fold_ty(cx.tcx, ty, |t| { match ty::get(t).sty { - ty::ty_box(_) => { - n_box += 1; - } ty::ty_uniq(_) | ty::ty_closure(box ty::ClosureTy { store: ty::UniqTraitStore, @@ -449,21 +439,13 @@ impl HeapMemory { let s = ty_to_string(cx.tcx, ty); let m = format!("type uses owned (Box type) pointers: {}", s); cx.span_lint(OWNED_HEAP_MEMORY, span, m.as_slice()); - cx.span_lint(HEAP_MEMORY, span, m.as_slice()); - } - - if n_box > 0 { - let s = ty_to_string(cx.tcx, ty); - let m = format!("type uses managed (@ type) pointers: {}", s); - cx.span_lint(MANAGED_HEAP_MEMORY, span, m.as_slice()); - cx.span_lint(HEAP_MEMORY, span, m.as_slice()); } } } impl LintPass for HeapMemory { fn get_lints(&self) -> LintArray { - lint_array!(MANAGED_HEAP_MEMORY, OWNED_HEAP_MEMORY, HEAP_MEMORY) + lint_array!(OWNED_HEAP_MEMORY) } fn check_item(&mut self, cx: &Context, it: &ast::Item) { diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index ce5494ef477..a07518cf3f2 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -397,7 +397,6 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { assert_eq!(next(st), '|'); return ty::mk_param(st.tcx, space, index, did); } - '@' => return ty::mk_box(st.tcx, parse_ty(st, |x,y| conv(x,y))), '~' => return ty::mk_uniq(st.tcx, parse_ty(st, |x,y| conv(x,y))), '*' => return ty::mk_ptr(st.tcx, parse_mt(st, |x,y| conv(x,y))), '&' => { diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index fd3e4fe6738..e3d8d0e5375 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -244,7 +244,6 @@ fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) { for t in ts.iter() { enc_ty(w, cx, *t); } mywrite!(w, "]"); } - ty::ty_box(typ) => { mywrite!(w, "@"); enc_ty(w, cx, typ); } ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); } ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); } ty::ty_rptr(r, mt) => { diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index a5111cdf7c8..e114eb88705 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -815,11 +815,6 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { return; } - mc::cat_deref(_, _, mc::GcPtr) => { - assert_eq!(cmt.mutbl, mc::McImmutable); - return; - } - mc::cat_rvalue(..) | mc::cat_static_item | mc::cat_deref(_, _, mc::UnsafePtr(..)) | diff --git a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs index 25439fce68c..1ae512a244c 100644 --- a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs @@ -132,7 +132,6 @@ fn check_and_get_illegal_move_origin(bccx: &BorrowckCtxt, match cmt.cat { mc::cat_deref(_, _, mc::BorrowedPtr(..)) | mc::cat_deref(_, _, mc::Implicit(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_deref(_, _, mc::UnsafePtr(..)) | mc::cat_upvar(..) | mc::cat_static_item | mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => { diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs index c0712332525..8ec58fe0eee 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs @@ -82,8 +82,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { mc::cat_downcast(ref base) | mc::cat_deref(ref base, _, mc::OwnedPtr) | // L-Deref-Send - mc::cat_interior(ref base, _) | // L-Field - mc::cat_deref(ref base, _, mc::GcPtr) => { + mc::cat_interior(ref base, _) => { // L-Field self.check(base, discr_scope) } @@ -185,7 +184,6 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { } mc::cat_downcast(ref cmt) | mc::cat_deref(ref cmt, _, mc::OwnedPtr) | - mc::cat_deref(ref cmt, _, mc::GcPtr) | mc::cat_interior(ref cmt, _) | mc::cat_discr(ref cmt, _) => { self.scope(cmt) diff --git a/src/librustc/middle/borrowck/gather_loans/move_error.rs b/src/librustc/middle/borrowck/gather_loans/move_error.rs index b826768c937..1b18d07f590 100644 --- a/src/librustc/middle/borrowck/gather_loans/move_error.rs +++ b/src/librustc/middle/borrowck/gather_loans/move_error.rs @@ -114,7 +114,6 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) { match move_from.cat { mc::cat_deref(_, _, mc::BorrowedPtr(..)) | mc::cat_deref(_, _, mc::Implicit(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_deref(_, _, mc::UnsafePtr(..)) | mc::cat_upvar(..) | mc::cat_static_item | mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => { diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index e0018919b98..067a73fcc9b 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -101,16 +101,13 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { self.extend(result, cmt.mutbl, LpInterior(i)) } - mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) | - mc::cat_deref(cmt_base, _, pk @ mc::GcPtr) => { + mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) => { // R-Deref-Send-Pointer // // When we borrow the interior of an owned pointer, we // cannot permit the base to be mutated, because that // would cause the unique pointer to be freed. // - // For a managed pointer, the rules are basically the - // same, because this could be the last ref. // Eventually we should make these non-special and // just rely on Deref implementation. let result = self.restrict(cmt_base); diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index b411620dac0..234afc7ae7a 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -730,11 +730,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { span, format!("{} in a static location", prefix).as_slice()); } - mc::AliasableManaged => { - self.tcx.sess.span_err( - span, - format!("{} in a `Gc` pointer", prefix).as_slice()); - } mc::AliasableBorrowed => { self.tcx.sess.span_err( span, diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index bef63ec3153..90d75b9554b 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -440,11 +440,6 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor, } } - ty::ty_box(_) => { - assert_eq!(pats_len, 1); - PatBox(pats.nth(0).unwrap()) - } - ty::ty_vec(_, Some(len)) => { assert_eq!(pats_len, len); PatVec(pats.collect(), None, vec![]) @@ -681,7 +676,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat, pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) -> uint { match ty::get(ty).sty { ty::ty_tup(ref fs) => fs.len(), - ty::ty_box(_) | ty::ty_uniq(_) => 1u, + ty::ty_uniq(_) => 1u, ty::ty_rptr(_, ty::mt { ty: ty, .. }) => match ty::get(ty).sty { ty::ty_vec(_, None) => match *ctor { Slice(length) => length, diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index dccb93f58cc..de291595ccc 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -28,8 +28,8 @@ fn type_size_is_affected_by_type_parameters(tcx: &ty::ctxt, typ: ty::t) let mut result = false; ty::maybe_walk_ty(typ, |typ| { match ty::get(typ).sty { - ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_ptr(_) | - ty::ty_rptr(..) | ty::ty_bare_fn(..) | ty::ty_closure(..) => { + ty::ty_uniq(_) | ty::ty_ptr(_) | ty::ty_rptr(..) | + ty::ty_bare_fn(..) | ty::ty_closure(..) => { false } ty::ty_param(_) => { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 50c92b45fdf..3c9ebd86b94 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -279,8 +279,6 @@ lets_do_this! { ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn; ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn; - MallocFnLangItem, "malloc", malloc_fn; - FreeFnLangItem, "free", free_fn; StrDupUniqFnLangItem, "strdup_uniq", strdup_uniq_fn; StartFnLangItem, "start", start_fn; @@ -293,9 +291,7 @@ lets_do_this! { EhPersonalityLangItem, "eh_personality", eh_personality; - ManagedHeapLangItem, "managed_heap", managed_heap; ExchangeHeapLangItem, "exchange_heap", exchange_heap; - GcLangItem, "gc", gc; OwnedBoxLangItem, "owned_box", owned_box; CovariantTypeItem, "covariant_type", covariant_type; diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index bb44b1f55cb..273360c9279 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -104,7 +104,6 @@ pub struct CopiedUpvar { #[deriving(Clone, PartialEq, Eq, Hash)] pub enum PointerKind { OwnedPtr, - GcPtr, BorrowedPtr(ty::BorrowKind, ty::Region), Implicit(ty::BorrowKind, ty::Region), // Implicit deref of a borrowed ptr. UnsafePtr(ast::Mutability) @@ -191,10 +190,6 @@ pub fn opt_deref_kind(t: ty::t) -> Option { Some(deref_ptr(BorrowedPtr(ty::ImmBorrow, r))) } - ty::ty_box(..) => { - Some(deref_ptr(GcPtr)) - } - ty::ty_ptr(ref mt) => { Some(deref_ptr(UnsafePtr(mt.mutbl))) } @@ -302,9 +297,6 @@ impl MutabilityCategory { BorrowedPtr(borrow_kind, _) | Implicit(borrow_kind, _) => { MutabilityCategory::from_borrow_kind(borrow_kind) } - GcPtr => { - McImmutable - } UnsafePtr(m) => { MutabilityCategory::from_mutbl(m) } @@ -1200,7 +1192,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { Implicit(..) => { "dereference (dereference is implicit, due to indexing)".to_string() } - OwnedPtr | GcPtr => format!("dereference of `{}`", ptr_sigil(pk)), + OwnedPtr => format!("dereference of `{}`", ptr_sigil(pk)), _ => format!("dereference of `{}`-pointer", ptr_sigil(pk)) } } @@ -1237,7 +1229,6 @@ pub enum InteriorSafety { } pub enum AliasableReason { - AliasableManaged, AliasableBorrowed, AliasableOther, AliasableStatic(InteriorSafety), @@ -1256,7 +1247,6 @@ impl cmt_ { cat_copied_upvar(..) | cat_local(..) | cat_deref(_, _, UnsafePtr(..)) | - cat_deref(_, _, GcPtr(..)) | cat_deref(_, _, BorrowedPtr(..)) | cat_deref(_, _, Implicit(..)) | cat_upvar(..) => { @@ -1320,10 +1310,6 @@ impl cmt_ { } } - cat_deref(_, _, GcPtr) => { - Some(AliasableManaged) - } - cat_deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) | cat_deref(_, _, Implicit(ty::ImmBorrow, _)) => { Some(AliasableBorrowed) @@ -1371,7 +1357,6 @@ impl Repr for categorization { pub fn ptr_sigil(ptr: PointerKind) -> &'static str { match ptr { OwnedPtr => "Box", - GcPtr => "Gc", BorrowedPtr(ty::ImmBorrow, _) | Implicit(ty::ImmBorrow, _) => "&", BorrowedPtr(ty::MutBorrow, _) | diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 9b179d3e895..080f9ff5bc7 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -104,11 +104,6 @@ pub fn ty_is_local(tcx: &ty::ctxt, krate == Some(ast::LOCAL_CRATE) || ty_is_local(tcx, t) } - ty::ty_box(t) => { - let krate = tcx.lang_items.gc().map(|d| d.krate); - krate == Some(ast::LOCAL_CRATE) || ty_is_local(tcx, t) - } - ty::ty_vec(t, _) | ty::ty_ptr(ty::mt { ty: t, .. }) | ty::ty_rptr(_, ty::mt { ty: t, .. }) => { diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 61477fdeed5..b86fabccf93 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -713,23 +713,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ok(self, Always) } - ty::ty_box(_) => { - match bound { - ty::BoundSync | - ty::BoundSend | - ty::BoundCopy => { - // Managed data is not copyable, sendable, nor - // synchronized, regardless of referent. - ok(self, Never) - } - - ty::BoundSized => { - // But it is sized, regardless of referent. - ok(self, Always) - } - } - } - ty::ty_uniq(referent_ty) => { // Box match bound { ty::BoundCopy => { diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 4d8e0145901..506b12de084 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -321,9 +321,6 @@ impl Case { _ => return Some(ThinPointer(i)) }, - // Gc is just a pointer - ty::ty_box(..) => return Some(ThinPointer(i)), - // Functions are just pointers ty::ty_bare_fn(..) => return Some(ThinPointer(i)), diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 03045777155..f65827753aa 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -397,36 +397,6 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Resu Result::new(bcx, llbox) } - -pub fn malloc_raw_dyn_managed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - t: ty::t, - alloc_fn: LangItem, - size: ValueRef) - -> Result<'blk, 'tcx> { - let _icx = push_ctxt("malloc_raw_dyn_managed"); - let ccx = bcx.ccx(); - - let langcall = require_alloc_fn(bcx, t, alloc_fn); - - // Grab the TypeRef type of box_ptr_ty. - let box_ptr_ty = ty::mk_box(bcx.tcx(), t); - let llty = type_of(ccx, box_ptr_ty); - let llalign = C_uint(ccx, type_of::align_of(ccx, box_ptr_ty) as uint); - - // Allocate space: - let drop_glue = glue::get_drop_glue(ccx, t); - let r = callee::trans_lang_call( - bcx, - langcall, - [ - PointerCast(bcx, drop_glue, Type::glue_fn(ccx, Type::i8p(ccx)).ptr_to()), - size, - llalign - ], - None); - Result::new(r.bcx, PointerCast(r.bcx, r.val, llty)) -} - // Type descriptor and type glue stuff pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> Rc { diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 35464be0e43..20fd0b0eb3d 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -960,7 +960,6 @@ impl Cleanup for DropValue { } pub enum Heap { - HeapManaged, HeapExchange } @@ -986,9 +985,6 @@ impl Cleanup for FreeValue { apply_debug_loc(bcx.fcx, debug_loc); match self.heap { - HeapManaged => { - glue::trans_free(bcx, self.ptr) - } HeapExchange => { glue::trans_exchange_free_ty(bcx, self.ptr, self.content_ty) } @@ -1019,9 +1015,6 @@ impl Cleanup for FreeSlice { apply_debug_loc(bcx.fcx, debug_loc); match self.heap { - HeapManaged => { - glue::trans_free(bcx, self.ptr) - } HeapExchange => { glue::trans_exchange_free_dyn(bcx, self.ptr, self.size, self.align) } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 30f91c82930..7daee22e614 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -71,7 +71,7 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool { use middle::trans::type_of::sizing_type_of; let tcx = ccx.tcx(); - let simple = ty::type_is_scalar(ty) || ty::type_is_boxed(ty) || + let simple = ty::type_is_scalar(ty) || ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) || type_is_newtype_immediate(ccx, ty) || ty::type_is_bot(ty) || ty::type_is_simd(tcx, ty); diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 84d9f2cb740..260bde0f07f 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -20,7 +20,6 @@ use middle::trans::common::*; use middle::trans::cleanup; use middle::trans::cleanup::CleanupMethods; use middle::trans::expr; -use middle::trans::glue; use middle::trans::tvec; use middle::trans::type_of; use middle::ty; @@ -240,14 +239,9 @@ impl KindOps for Lvalue { */ if ty::type_needs_drop(bcx.tcx(), ty) { - if ty::type_moves_by_default(bcx.tcx(), ty) { - // cancel cleanup of affine values by zeroing out - let () = zero_mem(bcx, val, ty); - bcx - } else { - // incr. refcount for @T or newtype'd @T - glue::take_ty(bcx, val, ty) - } + // cancel cleanup of affine values by zeroing out + let () = zero_mem(bcx, val, ty); + bcx } else { bcx } @@ -567,15 +561,15 @@ impl Datum { * is moved). */ - self.shallow_copy(bcx, dst); + self.shallow_copy_raw(bcx, dst); self.kind.post_store(bcx, self.val, self.ty) } - fn shallow_copy<'blk, 'tcx>(&self, - bcx: Block<'blk, 'tcx>, - dst: ValueRef) - -> Block<'blk, 'tcx> { + fn shallow_copy_raw<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + dst: ValueRef) + -> Block<'blk, 'tcx> { /*! * Helper function that performs a shallow copy of this value * into `dst`, which should be a pointer to a memory location @@ -584,10 +578,9 @@ impl Datum { * * This function is private to datums because it leaves memory * in an unstable state, where the source value has been - * copied but not zeroed. Public methods are `store_to` (if - * you no longer need the source value) or - * `shallow_copy_and_take` (if you wish the source value to - * remain valid). + * copied but not zeroed. Public methods are `store_to` + * (if you no longer need the source value) or `shallow_copy` + * (if you wish the source value to remain valid). */ let _icx = push_ctxt("copy_to_no_check"); @@ -605,22 +598,19 @@ impl Datum { return bcx; } - pub fn shallow_copy_and_take<'blk, 'tcx>(&self, - bcx: Block<'blk, 'tcx>, - dst: ValueRef) - -> Block<'blk, 'tcx> { + pub fn shallow_copy<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + dst: ValueRef) + -> Block<'blk, 'tcx> { /*! - * Copies the value into a new location and runs any necessary - * take glue on the new location. This function always + * Copies the value into a new location. This function always * preserves the existing datum as a valid value. Therefore, * it does not consume `self` and, also, cannot be applied to * affine values (since they must never be duplicated). */ assert!(!ty::type_moves_by_default(bcx.tcx(), self.ty)); - let mut bcx = bcx; - bcx = self.shallow_copy(bcx, dst); - glue::take_ty(bcx, dst, self.ty) + self.shallow_copy_raw(bcx, dst) } #[allow(dead_code)] // useful for debugging diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index dc328833d54..a29fd7f6ceb 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -373,12 +373,6 @@ impl TypeMap { unique_type_id.push_str(component_type_id.as_slice()); } }, - ty::ty_box(inner_type) => { - unique_type_id.push_char('@'); - let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type); - let inner_type_id = self.get_unique_type_id_as_string(inner_type_id); - unique_type_id.push_str(inner_type_id.as_slice()); - }, ty::ty_uniq(inner_type) => { unique_type_id.push_char('~'); let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type); @@ -596,18 +590,6 @@ impl TypeMap { let interner_key = self.unique_id_interner.intern(Rc::new(enum_variant_type_id)); UniqueTypeId(interner_key) } - - fn get_unique_type_id_of_gc_box(&mut self, - cx: &CrateContext, - element_type: ty::t) - -> UniqueTypeId { - let element_type_id = self.get_unique_type_id_of_type(cx, element_type); - let gc_box_type_id = format!("{{GC_BOX<{}>}}", - self.get_unique_type_id_as_string(element_type_id) - .as_slice()); - let interner_key = self.unique_id_interner.intern(Rc::new(gc_box_type_id)); - UniqueTypeId(interner_key) - } } // Returns from the enclosing function if the type metadata with the given @@ -2646,105 +2628,6 @@ fn create_struct_stub(cx: &CrateContext, return metadata_stub; } -fn at_box_metadata(cx: &CrateContext, - at_pointer_type: ty::t, - content_type: ty::t, - unique_type_id: UniqueTypeId) - -> MetadataCreationResult { - let content_type_metadata = type_metadata(cx, content_type, codemap::DUMMY_SP); - - return_if_metadata_created_in_meantime!(cx, unique_type_id); - - let content_type_name = compute_debuginfo_type_name(cx, content_type, true); - let content_type_name = content_type_name.as_slice(); - let content_llvm_type = type_of::type_of(cx, content_type); - - let box_type_name = format!("GcBox<{}>", content_type_name); - let box_llvm_type = Type::at_box(cx, content_llvm_type); - let member_llvm_types = box_llvm_type.field_types(); - assert!(box_layout_is_correct(cx, - member_llvm_types.as_slice(), - content_llvm_type)); - - let int_type = ty::mk_int(); - let nil_pointer_type = ty::mk_nil_ptr(cx.tcx()); - let nil_pointer_type_metadata = type_metadata(cx, - nil_pointer_type, - codemap::DUMMY_SP); - let member_descriptions = [ - MemberDescription { - name: "refcnt".to_string(), - llvm_type: *member_llvm_types.get(0), - type_metadata: type_metadata(cx, int_type, codemap::DUMMY_SP), - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "drop_glue".to_string(), - llvm_type: *member_llvm_types.get(1), - type_metadata: nil_pointer_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "prev".to_string(), - llvm_type: *member_llvm_types.get(2), - type_metadata: nil_pointer_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "next".to_string(), - llvm_type: *member_llvm_types.get(3), - type_metadata: nil_pointer_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "val".to_string(), - llvm_type: *member_llvm_types.get(4), - type_metadata: content_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - } - ]; - - let gc_box_unique_id = debug_context(cx).type_map - .borrow_mut() - .get_unique_type_id_of_gc_box(cx, content_type); - - let gc_box_metadata = composite_type_metadata( - cx, - box_llvm_type, - box_type_name.as_slice(), - gc_box_unique_id, - member_descriptions, - UNKNOWN_SCOPE_METADATA, - UNKNOWN_FILE_METADATA, - codemap::DUMMY_SP); - - let gc_pointer_metadata = pointer_type_metadata(cx, - at_pointer_type, - gc_box_metadata); - - return MetadataCreationResult::new(gc_pointer_metadata, false); - - // Unfortunately, we cannot assert anything but the correct types here---and - // not whether the 'next' and 'prev' pointers are in the correct order. - fn box_layout_is_correct(cx: &CrateContext, - member_llvm_types: &[Type], - content_llvm_type: Type) - -> bool { - member_llvm_types.len() == 5 && - member_llvm_types[0] == cx.int_type() && - member_llvm_types[1] == Type::generic_glue_fn(cx).ptr_to() && - member_llvm_types[2] == Type::i8(cx).ptr_to() && - member_llvm_types[3] == Type::i8(cx).ptr_to() && - member_llvm_types[4] == content_llvm_type - } -} - - fn fixed_vec_metadata(cx: &CrateContext, unique_type_id: UniqueTypeId, element_type: ty::t, @@ -2968,9 +2851,6 @@ fn type_metadata(cx: &CrateContext, ty::ty_enum(def_id, _) => { prepare_enum_metadata(cx, t, def_id, unique_type_id, usage_site_span).finalize(cx) } - ty::ty_box(pointee_type) => { - at_box_metadata(cx, t, pointee_type, unique_type_id) - } ty::ty_vec(typ, Some(len)) => { fixed_vec_metadata(cx, unique_type_id, typ, len, usage_site_span) } @@ -3702,7 +3582,7 @@ fn populate_scope_map(cx: &CrateContext, ast::ExprInlineAsm(ast::InlineAsm { inputs: ref inputs, outputs: ref outputs, .. }) => { - // inputs, outputs: ~[(String, Gc)] + // inputs, outputs: Vec<(String, P)> for &(_, ref exp) in inputs.iter() { walk_expr(cx, &**exp, scope_stack, scope_map); } @@ -3777,10 +3657,6 @@ fn push_debuginfo_type_name(cx: &CrateContext, push_debuginfo_type_name(cx, inner_type, true, output); output.push_char('>'); }, - ty::ty_box(inner_type) => { - output.push_char('@'); - push_debuginfo_type_name(cx, inner_type, true, output); - }, ty::ty_ptr(ty::mt { ty: inner_type, mutbl } ) => { output.push_char('*'); match mutbl { diff --git a/src/librustc/middle/trans/doc.rs b/src/librustc/middle/trans/doc.rs index 56bf2561338..d6df0d88a76 100644 --- a/src/librustc/middle/trans/doc.rs +++ b/src/librustc/middle/trans/doc.rs @@ -65,7 +65,7 @@ Some of the datum methods, however, are designed to work only on copyable values such as ints or pointers. Those methods may borrow the datum (`&self`) rather than consume it, but they always include assertions on the type of the value represented to check that this -makes sense. An example is `shallow_copy_and_take()`, which duplicates +makes sense. An example is `shallow_copy()`, which duplicates a datum value. Translating an expression always yields a `Datum` result, but diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 0b47544c562..cd4ad85d094 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -38,7 +38,6 @@ use llvm; use llvm::{ValueRef}; use metadata::csearch; use middle::def; -use middle::lang_items::MallocFnLangItem; use middle::mem_categorization::Typer; use middle::subst; use middle::subst::Subst; @@ -624,18 +623,15 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, DatumBlock::new(bcx, scratch.to_expr_datum()) } ast::ExprBox(_, ref contents) => { - // Special case for `Box` and `Gc` + // Special case for `Box` let box_ty = expr_ty(bcx, expr); let contents_ty = expr_ty(bcx, &**contents); match ty::get(box_ty).sty { ty::ty_uniq(..) => { trans_uniq_expr(bcx, box_ty, &**contents, contents_ty) } - ty::ty_box(..) => { - trans_managed_expr(bcx, box_ty, &**contents, contents_ty) - } _ => bcx.sess().span_bug(expr.span, - "expected unique or managed box") + "expected unique box") } } @@ -1572,26 +1568,6 @@ fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, immediate_rvalue_bcx(bcx, val, box_ty).to_expr_datumblock() } -fn trans_managed_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - box_ty: ty::t, - contents: &ast::Expr, - contents_ty: ty::t) - -> DatumBlock<'blk, 'tcx, Expr> { - let _icx = push_ctxt("trans_managed_expr"); - let fcx = bcx.fcx; - let ty = type_of::type_of(bcx.ccx(), contents_ty); - let Result {bcx, val: bx} = malloc_raw_dyn_managed(bcx, contents_ty, MallocFnLangItem, - llsize_of(bcx.ccx(), ty)); - let body = GEPi(bcx, bx, [0u, abi::box_field_body]); - - let custom_cleanup_scope = fcx.push_custom_cleanup_scope(); - fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope), - bx, cleanup::HeapManaged, contents_ty); - let bcx = trans_into(bcx, contents, SaveIn(body)); - fcx.pop_custom_cleanup_scope(custom_cleanup_scope); - immediate_rvalue_bcx(bcx, bx, box_ty).to_expr_datumblock() -} - fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr, subexpr: &ast::Expr) @@ -1924,10 +1900,6 @@ pub fn cast_type_kind(tcx: &ty::ctxt, t: ty::t) -> cast_kind { } fn cast_is_noop(t_in: ty::t, t_out: ty::t) -> bool { - if ty::type_is_boxed(t_in) || ty::type_is_boxed(t_out) { - return false; - } - match (ty::deref(t_in, true), ty::deref(t_out, true)) { (Some(ty::mt{ ty: t_in, .. }), Some(ty::mt{ ty: t_out, .. })) => { t_in == t_out @@ -2160,15 +2132,6 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } - ty::ty_box(content_ty) => { - let datum = unpack_datum!( - bcx, datum.to_lvalue_datum(bcx, "deref", expr.id)); - let llptrref = datum.to_llref(); - let llptr = Load(bcx, llptrref); - let llbody = GEPi(bcx, llptr, [0u, abi::box_field_body]); - DatumBlock::new(bcx, Datum::new(llbody, content_ty, LvalueExpr)) - } - ty::ty_ptr(ty::mt { ty: content_ty, .. }) | ty::ty_rptr(_, ty::mt { ty: content_ty, .. }) => { if ty::type_is_sized(bcx.tcx(), content_ty) { diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index c8cc89ca66a..33a46c0ba36 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -17,7 +17,7 @@ use back::abi; use back::link::*; use llvm::{ValueRef, True, get_param}; use llvm; -use middle::lang_items::{FreeFnLangItem, ExchangeFreeFnLangItem}; +use middle::lang_items::ExchangeFreeFnLangItem; use middle::subst; use middle::subst::Subst; use middle::trans::adt; @@ -46,15 +46,6 @@ use libc::c_uint; use syntax::ast; use syntax::parse::token; -pub fn trans_free<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef) - -> Block<'blk, 'tcx> { - let _icx = push_ctxt("trans_free"); - callee::trans_lang_call(cx, - langcall(cx, None, "", FreeFnLangItem), - [PointerCast(cx, v, Type::i8p(cx.ccx()))], - Some(expr::Ignore)).bcx -} - pub fn trans_exchange_free_dyn<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, size: ValueRef, align: ValueRef) -> Block<'blk, 'tcx> { @@ -87,20 +78,6 @@ pub fn trans_exchange_free_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef, } } -pub fn take_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v: ValueRef, t: ty::t) - -> Block<'blk, 'tcx> { - // NB: v is an *alias* of type t here, not a direct value. - let _icx = push_ctxt("take_ty"); - match ty::get(t).sty { - ty::ty_box(_) => incr_refcnt_of_boxed(bcx, v), - _ if ty::type_is_structural(t) - && ty::type_needs_drop(bcx.tcx(), t) => { - iter_structural_ty(bcx, v, t, take_ty) - } - _ => bcx - } -} - pub fn get_drop_glue_type(ccx: &CrateContext, t: ty::t) -> ty::t { let tcx = ccx.tcx(); // Even if there is no dtor for t, there might be one deeper down and we @@ -446,9 +423,6 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t) // NB: v0 is an *alias* of type t here, not a direct value. let _icx = push_ctxt("make_drop_glue"); match ty::get(t).sty { - ty::ty_box(body_ty) => { - decr_refcnt_maybe_free(bcx, v0, body_ty) - } ty::ty_uniq(content_ty) => { match ty::get(content_ty).sty { ty::ty_vec(ty, None) => { @@ -568,48 +542,6 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t) } } -fn decr_refcnt_maybe_free<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - box_ptr_ptr: ValueRef, - t: ty::t) -> Block<'blk, 'tcx> { - let _icx = push_ctxt("decr_refcnt_maybe_free"); - let fcx = bcx.fcx; - let ccx = bcx.ccx(); - - let decr_bcx = fcx.new_temp_block("decr"); - let free_bcx = fcx.new_temp_block("free"); - let next_bcx = fcx.new_temp_block("next"); - - let box_ptr = Load(bcx, box_ptr_ptr); - let llnotnull = IsNotNull(bcx, box_ptr); - CondBr(bcx, llnotnull, decr_bcx.llbb, next_bcx.llbb); - - let rc_ptr = GEPi(decr_bcx, box_ptr, [0u, abi::box_field_refcnt]); - let rc = Sub(decr_bcx, Load(decr_bcx, rc_ptr), C_int(ccx, 1)); - Store(decr_bcx, rc, rc_ptr); - CondBr(decr_bcx, IsNull(decr_bcx, rc), free_bcx.llbb, next_bcx.llbb); - - let v = Load(free_bcx, box_ptr_ptr); - let body = GEPi(free_bcx, v, [0u, abi::box_field_body]); - let free_bcx = drop_ty(free_bcx, body, t, None); - let free_bcx = trans_free(free_bcx, v); - Br(free_bcx, next_bcx.llbb); - - next_bcx -} - -fn incr_refcnt_of_boxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - box_ptr_ptr: ValueRef) -> Block<'blk, 'tcx> { - let _icx = push_ctxt("incr_refcnt_of_boxed"); - let ccx = bcx.ccx(); - let box_ptr = Load(bcx, box_ptr_ptr); - let rc_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_refcnt]); - let rc = Load(bcx, rc_ptr); - let rc = Add(bcx, rc, C_int(ccx, 1)); - Store(bcx, rc, rc_ptr); - bcx -} - - // Generates the declaration for (but doesn't emit) a type descriptor. pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> tydesc_info { // If emit_tydescs already ran, then we shouldn't be creating any new diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 03550299fbd..f004bea23c7 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -169,14 +169,6 @@ impl<'a, 'blk, 'tcx> Reflector<'a, 'blk, 'tcx> { extra.push(self.c_tydesc(ty)); self.visit("evec_fixed", extra.as_slice()) } - // Should remove mt from box and uniq. - ty::ty_box(typ) => { - let extra = self.c_mt(&ty::mt { - ty: typ, - mutbl: ast::MutImmutable, - }); - self.visit("box", extra.as_slice()) - } ty::ty_ptr(ref mt) => { match ty::get(mt.ty).sty { ty::ty_vec(ty, None) => { diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 848e59e2a60..fac0ef2014e 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -325,7 +325,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let bcx = iter_vec_loop(bcx, lldest, vt, C_uint(bcx.ccx(), count), |set_bcx, lleltptr, _| { - elem.shallow_copy_and_take(set_bcx, lleltptr) + elem.shallow_copy(set_bcx, lleltptr) }); elem.add_clean_if_rvalue(bcx, element.id); diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 54f24516867..d41cd7ed9e5 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -174,7 +174,6 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type { ty::ty_uint(t) => Type::uint_from_ty(cx, t), ty::ty_float(t) => Type::float_from_ty(cx, t), - ty::ty_box(..) => Type::i8p(cx), ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => { if ty::type_is_sized(cx.tcx(), ty) { Type::i8p(cx) @@ -299,9 +298,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { let name = llvm_type_name(cx, an_unboxed_closure, did, []); adt::incomplete_type_of(cx, &*repr, name.as_slice()) } - ty::ty_box(typ) => { - Type::at_box(cx, type_of(cx, typ)).ptr_to() - } ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => { match ty::get(ty).sty { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index b38f362dcf1..edbdf427c0b 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -940,7 +940,6 @@ pub enum sty { /// the `ast_ty_to_ty_cache`. This is probably true for `ty_struct` as /// well.` ty_enum(DefId, Substs), - ty_box(t), ty_uniq(t), ty_str, ty_vec(t, Option), // Second field is length. @@ -1621,7 +1620,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t { flags |= sflags(substs); flags |= flags_for_bounds(bounds); } - &ty_box(tt) | &ty_uniq(tt) | &ty_vec(tt, _) | &ty_open(tt) => { + &ty_uniq(tt) | &ty_vec(tt, _) | &ty_open(tt) => { flags |= get(tt).flags } &ty_ptr(ref m) => { @@ -1776,8 +1775,6 @@ pub fn mk_enum(cx: &ctxt, did: ast::DefId, substs: Substs) -> t { mk_t(cx, ty_enum(did, substs)) } -pub fn mk_box(cx: &ctxt, ty: t) -> t { mk_t(cx, ty_box(ty)) } - pub fn mk_uniq(cx: &ctxt, ty: t) -> t { mk_t(cx, ty_uniq(ty)) } pub fn mk_ptr(cx: &ctxt, tm: mt) -> t { mk_t(cx, ty_ptr(tm)) } @@ -1901,7 +1898,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) { match get(ty).sty { ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) | ty_str | ty_infer(_) | ty_param(_) | ty_unboxed_closure(_, _) | ty_err => {} - ty_box(ty) | ty_uniq(ty) | ty_vec(ty, _) | ty_open(ty) => maybe_walk_ty(ty, f), + ty_uniq(ty) | ty_vec(ty, _) | ty_open(ty) => maybe_walk_ty(ty, f), ty_ptr(ref tm) | ty_rptr(_, ref tm) => { maybe_walk_ty(tm.ty, f); } @@ -2014,7 +2011,7 @@ pub fn type_is_vec(ty: t) -> bool { match get(ty).sty { ty_vec(..) => true, ty_ptr(mt{ty: t, ..}) | ty_rptr(_, mt{ty: t, ..}) | - ty_box(t) | ty_uniq(t) => match get(t).sty { + ty_uniq(t) => match get(t).sty { ty_vec(_, None) => true, _ => false }, @@ -2067,13 +2064,6 @@ pub fn simd_size(cx: &ctxt, ty: t) -> uint { } } -pub fn type_is_boxed(ty: t) -> bool { - match get(ty).sty { - ty_box(_) => true, - _ => false - } -} - pub fn type_is_region_ptr(ty: t) -> bool { match get(ty).sty { ty_rptr(..) => true, @@ -2144,29 +2134,22 @@ pub fn type_needs_unwind_cleanup(cx: &ctxt, ty: t) -> bool { let mut tycache = HashSet::new(); let needs_unwind_cleanup = - type_needs_unwind_cleanup_(cx, ty, &mut tycache, false); + type_needs_unwind_cleanup_(cx, ty, &mut tycache); cx.needs_unwind_cleanup_cache.borrow_mut().insert(ty, needs_unwind_cleanup); - return needs_unwind_cleanup; + needs_unwind_cleanup } fn type_needs_unwind_cleanup_(cx: &ctxt, ty: t, - tycache: &mut HashSet, - encountered_box: bool) -> bool { + tycache: &mut HashSet) -> bool { // Prevent infinite recursion if !tycache.insert(ty) { return false; } - let mut encountered_box = encountered_box; let mut needs_unwind_cleanup = false; maybe_walk_ty(ty, |ty| { - let old_encountered_box = encountered_box; let result = match get(ty).sty { - ty_box(_) => { - encountered_box = true; - true - } ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_tup(_) | ty_ptr(_) => { true @@ -2176,33 +2159,21 @@ fn type_needs_unwind_cleanup_(cx: &ctxt, ty: t, for aty in v.args.iter() { let t = aty.subst(cx, substs); needs_unwind_cleanup |= - type_needs_unwind_cleanup_(cx, t, tycache, - encountered_box); + type_needs_unwind_cleanup_(cx, t, tycache); } } !needs_unwind_cleanup } - ty_uniq(_) => { - // Once we're inside a box, the annihilator will find - // it and destroy it. - if !encountered_box { - needs_unwind_cleanup = true; - false - } else { - true - } - } _ => { needs_unwind_cleanup = true; false } }; - encountered_box = old_encountered_box; result }); - return needs_unwind_cleanup; + needs_unwind_cleanup } /** @@ -2460,10 +2431,6 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { closure_contents(cx, &**c) | TC::ReachesFfiUnsafe } - ty_box(typ) => { - tc_ty(cx, typ, cache).managed_pointer() | TC::ReachesFfiUnsafe - } - ty_uniq(typ) => { TC::ReachesFfiUnsafe | match get(typ).sty { ty_str => TC::OwnsOwned, @@ -2782,7 +2749,7 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool { ty_vec(_, None) => { false } - ty_box(typ) | ty_uniq(typ) | ty_open(typ) => { + ty_uniq(typ) | ty_open(typ) => { type_requires(cx, seen, r_ty, typ) } ty_rptr(_, ref mt) => { @@ -3092,7 +3059,7 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: t) -> bool { // Some types---notably unsafe ptrs---can only be dereferenced explicitly. pub fn deref(t: t, explicit: bool) -> Option { match get(t).sty { - ty_box(ty) | ty_uniq(ty) => { + ty_uniq(ty) => { Some(mt { ty: ty, mutbl: ast::MutImmutable, @@ -3106,9 +3073,7 @@ pub fn deref(t: t, explicit: bool) -> Option { pub fn deref_or_dont(t: t) -> t { match get(t).sty { - ty_box(ty) | ty_uniq(ty) => { - ty - }, + ty_uniq(ty) => ty, ty_rptr(_, mt) | ty_ptr(mt) => mt.ty, _ => t } @@ -3124,7 +3089,7 @@ pub fn close_type(cx: &ctxt, t: t) -> t { pub fn type_content(t: t) -> t { match get(t).sty { - ty_box(ty) | ty_uniq(ty) => ty, + ty_uniq(ty) => ty, ty_rptr(_, mt) |ty_ptr(mt) => mt.ty, _ => t } @@ -3695,14 +3660,13 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind { } ast::ExprBox(ref place, _) => { - // Special case `Box`/`Gc` for now: + // Special case `Box` for now: let definition = match tcx.def_map.borrow().find(&place.id) { Some(&def) => def, None => fail!("no def for place"), }; let def_id = definition.def_id(); - if tcx.lang_items.exchange_heap() == Some(def_id) || - tcx.lang_items.managed_heap() == Some(def_id) { + if tcx.lang_items.exchange_heap() == Some(def_id) { RvalueDatumExpr } else { RvalueDpsExpr @@ -3753,7 +3717,6 @@ pub fn ty_sort_string(cx: &ctxt, t: t) -> String { } ty_enum(id, _) => format!("enum {}", item_path_str(cx, id)), - ty_box(_) => "Gc-ptr".to_string(), ty_uniq(_) => "box".to_string(), ty_vec(_, Some(_)) => "array".to_string(), ty_vec(_, None) => "unsized array".to_string(), @@ -5223,19 +5186,15 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 { byte!(8); did(&mut state, d); } - ty_box(_) => { + ty_uniq(_) => { byte!(9); } - ty_uniq(_) => { - byte!(10); - } ty_vec(_, Some(n)) => { - byte!(11); + byte!(10); n.hash(&mut state); } ty_vec(_, None) => { byte!(11); - 0u8.hash(&mut state); } ty_ptr(m) => { byte!(12); @@ -5586,7 +5545,6 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec, ty_int(_) | ty_uint(_) | ty_float(_) | - ty_box(_) | ty_uniq(_) | ty_str | ty_vec(_, _) | diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index 2e964c457bf..44420ddd7f3 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -458,9 +458,6 @@ pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T, pub fn super_fold_sty<'tcx, T: TypeFolder<'tcx>>(this: &mut T, sty: &ty::sty) -> ty::sty { match *sty { - ty::ty_box(typ) => { - ty::ty_box(typ.fold_with(this)) - } ty::ty_uniq(typ) => { ty::ty_uniq(typ.fold_with(this)) } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 72c3c1715e0..4d21090dd2c 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -559,44 +559,6 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( "not enough type parameters supplied to `Box`"); Some(ty::mk_err()) } - def::DefTy(did, _) | def::DefStruct(did) - if Some(did) == this.tcx().lang_items.gc() => { - if path.segments - .iter() - .flat_map(|s| s.types.iter()) - .count() > 1 { - span_err!(this.tcx().sess, path.span, E0048, - "`Gc` has only one type parameter"); - } - - for inner_ast_type in path.segments - .iter() - .flat_map(|s| s.types.iter()) { - return Some(mk_pointer(this, - rscope, - ast::MutImmutable, - &**inner_ast_type, - Box, - |typ| { - match ty::get(typ).sty { - ty::ty_str => { - span_err!(this.tcx().sess, path.span, E0114, - "`Gc` is not a type"); - ty::mk_err() - } - ty::ty_vec(_, None) => { - span_err!(this.tcx().sess, path.span, E0115, - "`Gc<[T]>` is not a type"); - ty::mk_err() - } - _ => ty::mk_box(this.tcx(), typ), - } - })) - } - this.tcx().sess.span_bug(path.span, - "not enough type parameters \ - supplied to `Gc`") - } _ => None } } @@ -606,7 +568,6 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( #[deriving(Show)] enum PointerTy { - Box, RPtr(ty::Region), Uniq } @@ -614,7 +575,6 @@ enum PointerTy { impl PointerTy { fn default_region(&self) -> ty::Region { match *self { - Box => ty::ReStatic, Uniq => ty::ReStatic, RPtr(r) => r, } @@ -702,14 +662,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( r, ty::mt {mutbl: a_seq_mutbl, ty: tr}); } - _ => { - tcx.sess.span_err( - a_seq_ty.span, - "~trait or &trait are the only supported \ - forms of casting-to-trait"); - return ty::mk_err(); - } - } } ast::TyPath(ref path, ref opt_bounds, id) => { @@ -726,11 +678,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( RPtr(r) => { return ty::mk_str_slice(tcx, r, ast::MutImmutable); } - _ => { - tcx.sess - .span_err(path.span, - "managed strings are not supported") - } } } Some(&def::DefTrait(trait_def_id)) => { @@ -767,13 +714,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( RPtr(r) => { return ty::mk_rptr(tcx, r, ty::mt{mutbl: a_seq_mutbl, ty: tr}); } - _ => { - tcx.sess.span_err( - path.span, - "~trait or &trait are the only supported \ - forms of casting-to-trait"); - return ty::mk_err(); - } }; } _ => {} diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 3d522a7c548..8711f4de512 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1094,7 +1094,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { let tcx = self.tcx(); match ty::get(self_ty).sty { - ty_bare_fn(..) | ty_box(..) | ty_uniq(..) | ty_rptr(..) | + ty_bare_fn(..) | ty_uniq(..) | ty_rptr(..) | ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_param(..) | ty_nil | ty_bot | ty_bool | diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index d8b5185a47a..194c2c35c88 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3820,12 +3820,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt, if tcx.lang_items.exchange_heap() == Some(def_id) { fcx.write_ty(id, ty::mk_uniq(tcx, referent_ty)); checked = true - } else if tcx.lang_items.managed_heap() == Some(def_id) { - fcx.register_region_obligation(infer::Managed(expr.span), - referent_ty, - ty::ReStatic); - fcx.write_ty(id, ty::mk_box(tcx, referent_ty)); - checked = true } } _ => {} diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 53edcb303f7..4d19bc16a3e 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -1466,7 +1466,6 @@ fn link_region(rcx: &Rcx, mc::cat_discr(cmt_base, _) | mc::cat_downcast(cmt_base) | - mc::cat_deref(cmt_base, _, mc::GcPtr(..)) | mc::cat_deref(cmt_base, _, mc::OwnedPtr) | mc::cat_interior(cmt_base, _) => { // Borrowing interior or owned data requires the base @@ -1699,7 +1698,6 @@ fn adjust_upvar_borrow_kind_for_mut(rcx: &Rcx, } mc::cat_deref(_, _, mc::UnsafePtr(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_static_item | mc::cat_rvalue(_) | mc::cat_copied_upvar(_) | @@ -1750,7 +1748,6 @@ fn adjust_upvar_borrow_kind_for_unique(rcx: &Rcx, cmt: mc::cmt) { } mc::cat_deref(_, _, mc::UnsafePtr(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_static_item | mc::cat_rvalue(_) | mc::cat_copied_upvar(_) | diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index db9877698a3..5d75d590a09 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -129,7 +129,6 @@ impl<'a, 'tcx> Wf<'a, 'tcx> { ty::ty_vec(t, _) | ty::ty_ptr(ty::mt { ty: t, .. }) | - ty::ty_box(t) | ty::ty_uniq(t) => { self.accumulate_from_ty(t) } diff --git a/src/librustc/middle/typeck/check/vtable2.rs b/src/librustc/middle/typeck/check/vtable2.rs index bdcf4d73c3b..1d765c6c7c6 100644 --- a/src/librustc/middle/typeck/check/vtable2.rs +++ b/src/librustc/middle/typeck/check/vtable2.rs @@ -95,7 +95,7 @@ pub fn check_object_cast(fcx: &FnCtxt, } } - // Because we currently give unsound lifetimes to the "ty_box", I + // Because we currently give unsound lifetimes to the "t_box", I // could have written &'static ty::TyTrait here, but it seems // gratuitously unsafe. fn object_trait<'a>(t: &'a ty::t) -> &'a ty::TyTrait { diff --git a/src/librustc/middle/typeck/coherence/mod.rs b/src/librustc/middle/typeck/coherence/mod.rs index cef6e31b937..f6ac0e1666c 100644 --- a/src/librustc/middle/typeck/coherence/mod.rs +++ b/src/librustc/middle/typeck/coherence/mod.rs @@ -23,7 +23,7 @@ use middle::subst::{Substs}; use middle::ty::get; use middle::ty::{ImplContainer, ImplOrTraitItemId, MethodTraitItemId}; use middle::ty::{TypeTraitItemId, lookup_item_type}; -use middle::ty::{t, ty_bool, ty_char, ty_bot, ty_box, ty_enum, ty_err}; +use middle::ty::{t, ty_bool, ty_char, ty_bot, ty_enum, ty_err}; use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil, ty_open}; use middle::ty::{ty_param, Polytype, ty_ptr}; use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup}; @@ -84,8 +84,8 @@ fn get_base_type(inference_context: &InferCtxt, ty_nil | ty_bot | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) | ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) | - ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | - ty_box(_) | ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => { + ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) | + ty_ptr(_) | ty_rptr(_, _) => { debug!("(getting base type) no base type; found {:?}", get(original_type).sty); None diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 7f9f569c37e..a0c190c5c81 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -258,7 +258,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let r_borrow = self.get_ref().infcx.next_region_var(coercion); let inner_ty = match *sty_a { - ty::ty_box(_) | ty::ty_uniq(_) => return Err(ty::terr_mismatch), + ty::ty_uniq(_) => return Err(ty::terr_mismatch), ty::ty_rptr(_, mt_a) => mt_a.ty, _ => { return self.subtype(a, b); diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 4412b7d94d4..a742cf45059 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -495,10 +495,6 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres { - this.tys(a_inner, b_inner).and_then(|typ| Ok(ty::mk_box(tcx, typ))) - } - (&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) => { let typ = try!(this.tys(a_inner, b_inner)); check_ptr_to_unsized(this, a, b, a_inner, b_inner, ty::mk_uniq(tcx, typ)) diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 0149220fde4..8ff5b3c9024 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -776,11 +776,6 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { sup, ""); } - infer::Managed(span) => { - self.tcx.sess.span_err( - span, - format!("cannot put borrowed references into managed memory").as_slice()); - } } } @@ -1612,11 +1607,6 @@ impl<'a, 'tcx> ErrorReportingHelpers for InferCtxt<'a, 'tcx> { does not outlive the data it points at", self.ty_to_string(ty)).as_slice()); } - infer::Managed(span) => { - self.tcx.sess.span_note( - span, - "...so that the value can be stored in managed memory."); - } infer::RelateParamBound(span, param_ty, t) => { self.tcx.sess.span_note( span, diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index c36192777f0..44bda134909 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -216,9 +216,6 @@ pub enum SubregionOrigin { // An auto-borrow that does not enclose the expr where it occurs AutoBorrow(Span), - - // Managed data cannot contain borrowed pointers. - Managed(Span), } /// Reasons to create a region inference variable @@ -1029,7 +1026,6 @@ impl SubregionOrigin { CallReturn(a) => a, AddrOf(a) => a, AutoBorrow(a) => a, - Managed(a) => a, } } } @@ -1102,7 +1098,6 @@ impl Repr for SubregionOrigin { CallReturn(a) => format!("CallReturn({})", a.repr(tcx)), AddrOf(a) => format!("AddrOf({})", a.repr(tcx)), AutoBorrow(a) => format!("AutoBorrow({})", a.repr(tcx)), - Managed(a) => format!("Managed({})", a.repr(tcx)), } } } diff --git a/src/librustc/middle/typeck/infer/skolemize.rs b/src/librustc/middle/typeck/infer/skolemize.rs index 4002f598449..54ece395be9 100644 --- a/src/librustc/middle/typeck/infer/skolemize.rs +++ b/src/librustc/middle/typeck/infer/skolemize.rs @@ -143,7 +143,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeSkolemizer<'a, 'tcx> { ty::ty_uint(..) | ty::ty_float(..) | ty::ty_enum(..) | - ty::ty_box(..) | ty::ty_uniq(..) | ty::ty_str | ty::ty_err | diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index a6edfcf80fd..9317ba2c7fa 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -742,7 +742,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { self.add_constraints_from_mt(mt, variance); } - ty::ty_uniq(typ) | ty::ty_box(typ) | ty::ty_vec(typ, _) | ty::ty_open(typ) => { + ty::ty_uniq(typ) | ty::ty_vec(typ, _) | ty::ty_open(typ) => { self.add_constraints_from_ty(typ, variance); } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 5ca6d08720f..18cf805bccb 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -17,7 +17,7 @@ use middle::ty::{ReEarlyBound, BrFresh, ctxt}; use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, ReEmpty}; use middle::ty::{ReSkolemized, ReVar}; use middle::ty::{mt, t, ParamTy}; -use middle::ty::{ty_bool, ty_char, ty_bot, ty_box, ty_struct, ty_enum}; +use middle::ty::{ty_bool, ty_char, ty_bot, ty_struct, ty_enum}; use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn, ty_closure}; use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_tup, ty_open}; use middle::ty::{ty_unboxed_closure}; @@ -375,7 +375,6 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { ty_int(t) => ast_util::int_ty_to_string(t, None).to_string(), ty_uint(t) => ast_util::uint_ty_to_string(t, None).to_string(), ty_float(t) => ast_util::float_ty_to_string(t).to_string(), - ty_box(typ) => format!("Gc<{}>", ty_to_string(cx, typ)), ty_uniq(typ) => format!("Box<{}>", ty_to_string(cx, typ)), ty_ptr(ref tm) => { format!("*{} {}", match tm.mutbl { From 39de8464ed16e00c716faff2782fef6babbb090b Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 01:42:04 +0300 Subject: [PATCH 25/43] rustdoc: remove handling of Gc. --- src/librustdoc/clean/mod.rs | 7 ------- src/librustdoc/html/format.rs | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index cb5c633bd25..e251544b5be 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1087,7 +1087,6 @@ pub enum Type { /// aka TyBot Bottom, Unique(Box), - Managed(Box), RawPointer(Mutability, Box), BorrowedRef { pub lifetime: Option, @@ -1253,12 +1252,6 @@ impl Clean for ty::t { ty::ty_float(ast::TyF32) => Primitive(F32), ty::ty_float(ast::TyF64) => Primitive(F64), ty::ty_str => Primitive(Str), - ty::ty_box(t) => { - let gc_did = cx.tcx_opt().and_then(|tcx| { - tcx.lang_items.gc() - }); - lang_struct(cx, gc_did, t, "Gc", Managed) - } ty::ty_uniq(t) => { let box_did = cx.tcx_opt().and_then(|tcx| { tcx.lang_items.owned_box() diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index b52b34ff581..6a001b32470 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -476,7 +476,7 @@ impl fmt::Show for clean::Type { }; write!(f, "&{}{}{}", lt, MutableSpace(mutability), **ty) } - clean::Unique(..) | clean::Managed(..) => { + clean::Unique(..) => { fail!("should have been cleaned") } } From aa0b350c9798ca1ca1b0b82aec66f7ee2bac76ff Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 1 Oct 2014 01:45:17 +0300 Subject: [PATCH 26/43] docs: remove mentions of Gc. --- src/doc/guide-pointers.md | 13 ---- src/doc/guide-runtime.md | 1 - src/doc/guide-unsafe.md | 4 +- src/doc/reference.md | 2 +- src/librustc/middle/borrowck/doc.rs | 110 +++++----------------------- 5 files changed, 20 insertions(+), 110 deletions(-) diff --git a/src/doc/guide-pointers.md b/src/doc/guide-pointers.md index b920ffbdd1a..dd9c6871722 100644 --- a/src/doc/guide-pointers.md +++ b/src/doc/guide-pointers.md @@ -632,19 +632,6 @@ This part is coming soon. This part is coming soon. -# Gc - -The `Gc` type exists for historical reasons, and is [still used -internally](https://github.com/rust-lang/rust/issues/7929) by the compiler. -It is not even a 'real' garbage collected type at the moment. - -In the future, Rust may have a real garbage collected type, and so it -has not yet been removed for that reason. - -## Best practices - -There is currently no legitimate use case for the `Gc` type. - # Raw Pointers This part is coming soon. diff --git a/src/doc/guide-runtime.md b/src/doc/guide-runtime.md index 66a1e46c82a..578ff0edf14 100644 --- a/src/doc/guide-runtime.md +++ b/src/doc/guide-runtime.md @@ -31,7 +31,6 @@ list): * Task synchronization * Task-local storage * Logging -* Local heaps (GC heaps) * Task unwinding ## What is the runtime accomplishing? diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index 1e67c8a13e9..fe6664bd848 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -208,9 +208,7 @@ pub struct Unique { // Implement methods for creating and using the values in the box. // NB: For simplicity and correctness, we require that T has kind Send -// (owned boxes relax this restriction, and can contain managed (GC) boxes). -// This is because, as implemented, the garbage collector would not know -// about any shared boxes stored in the malloc'd region of memory. +// (owned boxes relax this restriction). impl Unique { pub fn new(value: T) -> Unique { unsafe { diff --git a/src/doc/reference.md b/src/doc/reference.md index c3b61f6435c..ecd583937f4 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3381,7 +3381,7 @@ fn main() { ``` -Patterns can also dereference pointers by using the `&`, `box` or `@` symbols, +Patterns can also dereference pointers by using the `&`, `box` symbols, as appropriate. For example, these two matches on `x: &int` are equivalent: ``` diff --git a/src/librustc/middle/borrowck/doc.rs b/src/librustc/middle/borrowck/doc.rs index 9fc291d3971..882b6bc8426 100644 --- a/src/librustc/middle/borrowck/doc.rs +++ b/src/librustc/middle/borrowck/doc.rs @@ -74,7 +74,7 @@ to an `LV` of `(*a).f`. Here is the formal grammar for the types we'll consider: ```text -TY = () | S<'LT...> | Box | & 'LT MQ TY | @ MQ TY +TY = () | S<'LT...> | Box | & 'LT MQ TY MQ = mut | imm | const ``` @@ -263,9 +263,7 @@ compatible with the aliasability of `LV`. The goal is to prevent `&mut` borrows of aliasability data. 3. `LIFETIME(LV, LT, MQ)`: The lifetime of the borrow does not exceed -the lifetime of the value being borrowed. This pass is also -responsible for inserting root annotations to keep managed values -alive. +the lifetime of the value being borrowed. 4. `RESTRICTIONS(LV, LT, ACTIONS) = RS`: This pass checks and computes the restrictions to maintain memory safety. These are the restrictions @@ -316,17 +314,13 @@ MUTABILITY(*LV, MQ) // M-Deref-Unique ### Checking mutability of immutable pointer types -Immutable pointer types like `&T` and `@T` can only +Immutable pointer types like `&T` can only be borrowed if MQ is immutable or const: ```text MUTABILITY(*LV, MQ) // M-Deref-Borrowed-Imm TYPE(LV) = &Ty MQ == imm | const - -MUTABILITY(*LV, MQ) // M-Deref-Managed-Imm - TYPE(LV) = @Ty - MQ == imm | const ``` ### Checking mutability of mutable pointer types @@ -390,11 +384,10 @@ ALIASABLE(*LV, MQ) // M-Deref-Borrowed-Mut ## Checking lifetime These rules aim to ensure that no data is borrowed for a scope that exceeds -its lifetime. In addition, these rules manage the rooting of `@` values. -These two computations wind up being intimately related. Formally, we define -a predicate `LIFETIME(LV, LT, MQ)`, which states that "the lvalue `LV` can be -safely borrowed for the lifetime `LT` with mutability `MQ`". The Rust -code corresponding to this predicate is the module +its lifetime. These two computations wind up being intimately related. +Formally, we define a predicate `LIFETIME(LV, LT, MQ)`, which states that +"the lvalue `LV` can be safely borrowed for the lifetime `LT` with mutability +`MQ`". The Rust code corresponding to this predicate is the module `middle::borrowck::gather_loans::lifetime`. ### The Scope function @@ -423,14 +416,6 @@ the pointer itself `LV` goes out of scope: SCOPE(*LV) = SCOPE(LV) if LV has type Box ``` -The scope of a managed referent is also the scope of the pointer. This -is a conservative approximation, since there may be other aliases for -that same managed box that would cause it to live longer: - -```text - SCOPE(*LV) = SCOPE(LV) if LV has type @T -``` - The scope of a borrowed referent is the scope associated with the pointer. This is a conservative approximation, since the data that the pointer points at may actually live longer: @@ -477,59 +462,6 @@ LIFETIME(*LV, LT, MQ) // L-Deref-Borrowed LT <= LT' ``` -### Checking lifetime for derefs of managed, immutable pointers - -Managed pointers are valid so long as the data within them is -*rooted*. There are two ways that this can be achieved. The first is -when the user guarantees such a root will exist. For this to be true, -three conditions must be met: - -```text -LIFETIME(*LV, LT, MQ) // L-Deref-Managed-Imm-User-Root - TYPE(LV) = @Ty - LT <= SCOPE(LV) // (1) - LV is immutable // (2) - LV is not moved or not movable // (3) -``` - -Condition (1) guarantees that the managed box will be rooted for at -least the lifetime `LT` of the borrow, presuming that no mutation or -moves occur. Conditions (2) and (3) then serve to guarantee that the -value is not mutated or moved. Note that lvalues are either -(ultimately) owned by a local variable, in which case we can check -whether that local variable is ever moved in its scope, or they are -owned by the referent of an (immutable, due to condition 2) managed or -references, in which case moves are not permitted because the -location is aliasable. - -If the conditions of `L-Deref-Managed-Imm-User-Root` are not met, then -there is a second alternative. The compiler can attempt to root the -managed pointer itself. This permits great flexibility, because the -location `LV` where the managed pointer is found does not matter, but -there are some limitations. The lifetime of the borrow can only extend -to the innermost enclosing loop or function body. This guarantees that -the compiler never requires an unbounded amount of stack space to -perform the rooting; if this condition were violated, the compiler -might have to accumulate a list of rooted objects, for example if the -borrow occurred inside the body of a loop but the scope of the borrow -extended outside the loop. More formally, the requirement is that -there is no path starting from the borrow that leads back to the -borrow without crossing the exit from the scope `LT`. - -The rule for compiler rooting is as follows: - -```text -LIFETIME(*LV, LT, MQ) // L-Deref-Managed-Imm-Compiler-Root - TYPE(LV) = @Ty - LT <= innermost enclosing loop/func - ROOT LV at *LV for LT -``` - -Here I have written `ROOT LV at *LV FOR LT` to indicate that the code -makes a note in a side-table that the box `LV` must be rooted into the -stack when `*LV` is evaluated, and that this root can be released when -the scope `LT` exits. - ## Computing the restrictions The final rules govern the computation of *restrictions*, meaning that @@ -599,22 +531,18 @@ RESTRICTIONS(*LV, LT, ACTIONS) = RS, (*LV, ACTIONS) // R-Deref-Send-Pointer RESTRICTIONS(LV, LT, ACTIONS|MUTATE|CLAIM) = RS ``` -### Restrictions for loans of immutable managed/borrowed referents +### Restrictions for loans of immutable borrowed referents -Immutable managed/borrowed referents are freely aliasable, meaning that +Immutable borrowed referents are freely aliasable, meaning that the compiler does not prevent you from copying the pointer. This implies that issuing restrictions is useless. We might prevent the user from acting on `*LV` itself, but there could be another path `*LV1` that refers to the exact same memory, and we would not be -restricting that path. Therefore, the rule for `&Ty` and `@Ty` -pointers always returns an empty set of restrictions, and it only -permits restricting `MUTATE` and `CLAIM` actions: +restricting that path. Therefore, the rule for `&Ty` pointers +always returns an empty set of restrictions, and it only permits +restricting `MUTATE` and `CLAIM` actions: ```text -RESTRICTIONS(*LV, LT, ACTIONS) = [] // R-Deref-Imm-Managed - TYPE(LV) = @Ty - ACTIONS subset of [MUTATE, CLAIM] - RESTRICTIONS(*LV, LT, ACTIONS) = [] // R-Deref-Imm-Borrowed TYPE(LV) = <' Ty LT <= LT' // (1) @@ -623,8 +551,8 @@ RESTRICTIONS(*LV, LT, ACTIONS) = [] // R-Deref-Imm-Borrowed The reason that we can restrict `MUTATE` and `CLAIM` actions even without a restrictions list is that it is never legal to mutate nor to -borrow mutably the contents of a `&Ty` or `@Ty` pointer. In other -words, those restrictions are already inherent in the type. +borrow mutably the contents of a `&Ty` pointer. In other words, +those restrictions are already inherent in the type. Clause (1) in the rule for `&Ty` deserves mention. Here I specify that the lifetime of the loan must be less than the lifetime @@ -729,13 +657,12 @@ are affine.) Freeze pointers are read-only. There may be `&mut` or `&` aliases, and we can not prevent *anything* but moves in that case. So the `RESTRICTIONS` function is only defined if `ACTIONS` is the empty set. -Because moves from a `&const` or `@const` lvalue are never legal, it -is not necessary to add any restrictions at all to the final -result. +Because moves from a `&const` lvalue are never legal, it is not +necessary to add any restrictions at all to the final result. ```text RESTRICTIONS(*LV, LT, []) = [] // R-Deref-Freeze-Borrowed - TYPE(LV) = &const Ty or @const Ty + TYPE(LV) = &const Ty ``` ### Restrictions for loans of mutable borrowed referents @@ -957,8 +884,7 @@ moves and the declaration of uninitialized variables. For each of these points, we create a bit in the dataflow set. Assignments to a variable `x` or path `a.b.c` kill the move/uninitialization bits for those paths and any subpaths (e.g., `x`, `x.y`, `a.b.c`, `*a.b.c`). -The bits are also killed when the root variables (`x`, `a`) go out of -scope. Bits are unioned when two control-flow paths join. Thus, the +Bits are unioned when two control-flow paths join. Thus, the presence of a bit indicates that the move may have occurred without an intervening assignment to the same memory. At each use of a variable, we examine the bits in scope, and check that none of them are From db55e70c977f9e2a70e62ea819755ef02009db8e Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Thu, 2 Oct 2014 00:19:55 +0300 Subject: [PATCH 27/43] syntax: mark the managed_boxes feature as Removed. --- src/libcollections/lib.rs | 2 +- src/libcore/lib.rs | 2 +- src/libdebug/lib.rs | 2 +- src/libfourcc/lib.rs | 2 +- src/libhexfloat/lib.rs | 2 +- src/libregex_macros/lib.rs | 2 +- src/librustdoc/lib.rs | 2 +- src/librustrt/lib.rs | 2 +- src/libserialize/lib.rs | 2 +- src/libstd/lib.rs | 2 +- src/libsyntax/feature_gate.rs | 2 +- src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 4d0aaf83907..b74324c85c0 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -20,7 +20,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![allow(unknown_features)] -#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)] +#![feature(macro_rules, default_type_params, phase, globs)] #![feature(unsafe_destructor, import_shadowing, slicing_syntax)] #![no_std] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 4890dc2bb73..584d09c75c8 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -58,7 +58,7 @@ #![no_std] #![allow(unknown_features)] -#![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)] +#![feature(globs, intrinsics, lang_items, macro_rules, phase)] #![feature(simd, unsafe_destructor, slicing_syntax)] #![deny(missing_doc)] diff --git a/src/libdebug/lib.rs b/src/libdebug/lib.rs index 6341a380563..21abfae8be9 100644 --- a/src/libdebug/lib.rs +++ b/src/libdebug/lib.rs @@ -25,7 +25,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] #![experimental] -#![feature(managed_boxes, macro_rules)] +#![feature(macro_rules)] #![allow(experimental)] pub mod fmt; diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index 3aa40058792..388373807d8 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -50,7 +50,7 @@ fn main() { html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] -#![feature(plugin_registrar, managed_boxes)] +#![feature(plugin_registrar)] extern crate syntax; extern crate rustc; diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs index ae7a3e66dfd..2fcc3b9691a 100644 --- a/src/libhexfloat/lib.rs +++ b/src/libhexfloat/lib.rs @@ -46,7 +46,7 @@ fn main() { #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] -#![feature(plugin_registrar, managed_boxes)] +#![feature(plugin_registrar)] extern crate syntax; extern crate rustc; diff --git a/src/libregex_macros/lib.rs b/src/libregex_macros/lib.rs index 3535038b6a5..67018769fb3 100644 --- a/src/libregex_macros/lib.rs +++ b/src/libregex_macros/lib.rs @@ -19,7 +19,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] -#![feature(plugin_registrar, managed_boxes, quote)] +#![feature(plugin_registrar, quote)] extern crate regex; extern crate syntax; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index b46d8727b69..77d63224fcd 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -16,7 +16,7 @@ #![crate_type = "rlib"] #![allow(unknown_features)] -#![feature(globs, struct_variant, managed_boxes, macro_rules, phase, slicing_syntax)] +#![feature(globs, struct_variant, macro_rules, phase, slicing_syntax)] extern crate arena; extern crate debug; diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index ad1eac41e4d..d3ea07291a4 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -17,7 +17,7 @@ html_root_url = "http://doc.rust-lang.org/master/")] #![allow(unknown_features)] -#![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)] +#![feature(macro_rules, phase, globs, thread_local, asm)] #![feature(linkage, lang_items, unsafe_destructor, default_type_params)] #![feature(import_shadowing, slicing_syntax)] #![no_std] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 8c2f3235322..6de8ca19844 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -24,7 +24,7 @@ Core encoding and decoding interfaces. html_root_url = "http://doc.rust-lang.org/master/", html_playground_url = "http://play.rust-lang.org/")] #![allow(unknown_features)] -#![feature(macro_rules, managed_boxes, default_type_params, phase, slicing_syntax)] +#![feature(macro_rules, default_type_params, phase, slicing_syntax)] // test harness access #[cfg(test)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index f6c37b6cfc3..19b4d430562 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -106,7 +106,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![allow(unknown_features)] -#![feature(macro_rules, globs, managed_boxes, linkage)] +#![feature(macro_rules, globs, linkage)] #![feature(default_type_params, phase, lang_items, unsafe_destructor)] #![feature(import_shadowing, slicing_syntax)] diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 8565bebe269..7dcc039a83f 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -40,7 +40,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("struct_variant", Active), ("once_fns", Active), ("asm", Active), - ("managed_boxes", Active), + ("managed_boxes", Removed), ("non_ascii_idents", Active), ("thread_local", Active), ("link_args", Active), diff --git a/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs b/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs index ee5bc55b3fd..bb57b4a98bb 100644 --- a/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs +++ b/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs @@ -11,7 +11,7 @@ // ignore-stage1 // force-host -#![feature(plugin_registrar, managed_boxes, quote)] +#![feature(plugin_registrar, quote)] #![crate_type = "dylib"] extern crate syntax; From aa59693565efea3d55a6981b135df77c37c361fc Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Thu, 2 Oct 2014 00:29:16 +0300 Subject: [PATCH 28/43] syntax: remove ObsoleteManaged{Type,Expr}. --- src/libsyntax/parse/obsolete.rs | 10 ---------- src/libsyntax/parse/parser.rs | 14 -------------- 2 files changed, 24 deletions(-) diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index d47231bc3e2..1a6fb9b85dd 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -31,8 +31,6 @@ pub enum ObsoleteSyntax { ObsoleteOwnedPattern, ObsoleteOwnedVector, ObsoleteOwnedSelf, - ObsoleteManagedType, - ObsoleteManagedExpr, ObsoleteImportRenaming, ObsoleteSubsliceMatch, ObsoleteExternCrateRenaming, @@ -77,14 +75,6 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { "`~self` is no longer supported", "write `self: Box` instead" ), - ObsoleteManagedType => ( - "`@` notation for managed pointers", - "use `Gc` in `std::gc` instead" - ), - ObsoleteManagedExpr => ( - "`@` notation for a managed pointer allocation", - "use the `box(GC)` operator instead of `@`" - ), ObsoleteImportRenaming => ( "`use foo = bar` syntax", "write `use bar as foo` instead" diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8082fd65f1a..7cce9c2dc3a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1449,12 +1449,6 @@ impl<'a> Parser<'a> { t } } - } else if self.token == token::AT { - // MANAGED POINTER - self.bump(); - let span = self.last_span; - self.obsolete(span, ObsoleteManagedType); - TyUniq(self.parse_ty(plus_allowed)) } else if self.token == token::TILDE { // OWNED POINTER self.bump(); @@ -2722,14 +2716,6 @@ impl<'a> Parser<'a> { hi = e.span.hi; ex = ExprAddrOf(m, e); } - token::AT => { - self.bump(); - let span = self.last_span; - self.obsolete(span, ObsoleteManagedExpr); - let e = self.parse_prefix_expr(); - hi = e.span.hi; - ex = self.mk_unary(UnUniq, e); - } token::TILDE => { self.bump(); let last_span = self.last_span; From 58bea31ca0e11bf49439d33e1d21f11de7161567 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Thu, 2 Oct 2014 08:10:09 +0300 Subject: [PATCH 29/43] tests: remove uses of Gc. --- src/liballoc/rc.rs | 8 - src/libcollections/ringbuf.rs | 44 ----- src/libcoretest/iter.rs | 5 +- src/libdebug/repr.rs | 4 - src/librustrt/local_data.rs | 17 +- src/librustrt/task.rs | 34 +--- src/test/auxiliary/cci_nested_lib.rs | 7 +- .../crate-method-reexport-grrrrrrr2.rs | 3 +- src/test/auxiliary/issue-2631-a.rs | 4 +- src/test/auxiliary/issue-5521.rs | 3 +- src/test/auxiliary/issue13507.rs | 2 - src/test/bench/task-perf-alloc-unwind.rs | 28 +-- src/test/compile-fail/autoderef-full-lval.rs | 27 ++- ...orrowck-borrow-immut-deref-of-gc-as-mut.rs | 25 --- .../borrowck-managed-pointer-deref-scope.rs | 34 ---- .../borrowck-preserve-box-in-field.rs | 38 ---- .../borrowck-preserve-box-in-uniq.rs | 38 ---- .../compile-fail/borrowck-preserve-box.rs | 36 ---- .../borrowck-preserve-cond-box.rs | 46 ----- .../borrowck-preserve-expl-deref.rs | 38 ---- src/test/compile-fail/box-static-bound.rs | 22 --- .../check-static-values-constraints.rs | 4 - .../compile-fail/core-tls-store-pointer.rs | 6 +- src/test/compile-fail/issue-14915.rs | 4 - src/test/compile-fail/issue-2063-resource.rs | 11 +- src/test/compile-fail/issue-3668.rs | 11 +- src/test/compile-fail/issue-3763.rs | 5 - src/test/compile-fail/issue-7061.rs | 7 +- src/test/compile-fail/issue-7364.rs | 3 +- src/test/compile-fail/kindck-copy.rs | 4 +- .../compile-fail/kindck-destructor-owned.rs | 4 +- src/test/compile-fail/kindck-nonsendable-1.rs | 6 +- src/test/compile-fail/lint-heap-memory.rs | 30 ---- .../compile-fail/lint-managed-heap-memory.rs | 23 --- src/test/compile-fail/new-box-syntax-bad.rs | 24 --- src/test/compile-fail/no-send-res-ports.rs | 12 +- src/test/compile-fail/occurs-check-2.rs | 3 +- src/test/compile-fail/occurs-check.rs | 4 +- src/test/compile-fail/pinned-deep-copy.rs | 50 ------ .../regions-appearance-constraint.rs | 36 ---- .../regions-infer-borrow-scope-too-big.rs | 4 +- .../regions-infer-borrow-scope-within-loop.rs | 4 +- .../regions-infer-paramd-indirect.rs | 16 +- src/test/compile-fail/static-region-bound.rs | 4 +- .../struct-field-assignability.rs | 4 +- src/test/compile-fail/terr-sorts.rs | 6 +- .../trait-impl-method-mismatch.rs | 6 +- src/test/compile-fail/unique-unique-kind.rs | 4 +- src/test/compile-fail/unique-vec-res.rs | 17 +- src/test/compile-fail/unsendable-class.rs | 8 +- src/test/debuginfo/borrowed-managed-basic.rs | 166 ------------------ src/test/debuginfo/borrowed-struct.rs | 25 --- src/test/debuginfo/borrowed-tuple.rs | 11 -- src/test/debuginfo/box.rs | 12 -- src/test/debuginfo/boxed-struct.rs | 17 -- .../by-value-self-argument-in-trait-impl.rs | 19 -- src/test/debuginfo/managed-enum.rs | 85 --------- .../managed-pointer-within-unique-vec.rs | 63 ------- .../managed-pointer-within-unique.rs | 62 ------- src/test/debuginfo/recursive-struct.rs | 98 ----------- .../var-captured-in-nested-closure.rs | 13 +- .../var-captured-in-stack-closure.rs | 9 +- src/test/pretty/block-disambig.rs | 17 +- src/test/run-fail/args-fail.rs | 6 +- src/test/run-fail/issue-2272.rs | 29 --- src/test/run-fail/unwind-assert.rs | 19 -- src/test/run-fail/unwind-box-fn-unique.rs | 29 --- src/test/run-fail/unwind-box-res.rs | 50 ------ src/test/run-fail/unwind-box-str.rs | 26 --- src/test/run-fail/unwind-box-unique-unique.rs | 26 --- src/test/run-fail/unwind-box-unique.rs | 26 --- src/test/run-fail/unwind-box-vec.rs | 26 --- src/test/run-fail/unwind-box.rs | 23 --- src/test/run-fail/unwind-fail.rs | 19 -- .../run-fail/unwind-initializer-indirect.rs | 20 --- src/test/run-fail/unwind-initializer.rs | 20 --- src/test/run-fail/unwind-iter.rs | 26 --- src/test/run-fail/unwind-iter2.rs | 23 --- src/test/run-fail/unwind-lambda.rs | 32 ---- src/test/run-fail/unwind-match.rs | 28 --- src/test/run-fail/unwind-misc-1.rs | 31 ---- src/test/run-fail/unwind-move.rs | 23 --- src/test/run-fail/unwind-nested.rs | 24 --- src/test/run-fail/unwind-partial-box.rs | 31 ---- src/test/run-fail/unwind-partial-unique.rs | 31 ---- src/test/run-fail/unwind-partial-vec.rs | 31 ---- src/test/run-fail/unwind-resource-fail.rs | 29 --- src/test/run-fail/unwind-resource-fail2.rs | 30 ---- src/test/run-fail/unwind-resource-fail3.rs | 33 ---- src/test/run-fail/unwind-stacked.rs | 29 --- src/test/run-fail/unwind-tup.rs | 22 --- src/test/run-fail/unwind-tup2.rs | 26 --- src/test/run-fail/unwind-uninitialized.rs | 23 --- src/test/run-pass/assert-eq-macro-success.rs | 3 - .../run-pass/autoderef-method-priority.rs | 6 +- .../autoref-intermediate-types-issue-3585.rs | 10 +- src/test/run-pass/binops.rs | 8 - .../borrowck-borrow-from-expr-block.rs | 6 +- .../borrowck-preserve-box-in-moved-value.rs | 37 ---- .../run-pass/borrowck-root-while-cond-2.rs | 20 --- src/test/run-pass/borrowck-root-while-cond.rs | 21 --- src/test/run-pass/borrowck-univariant-enum.rs | 5 +- src/test/run-pass/box-compare.rs | 20 --- src/test/run-pass/box-in-tup.rs | 17 -- src/test/run-pass/box-inside-if.rs | 24 --- src/test/run-pass/box-inside-if2.rs | 24 --- src/test/run-pass/box-pattern.rs | 20 --- src/test/run-pass/box-unbox.rs | 23 --- src/test/run-pass/box.rs | 14 -- .../run-pass/boxed-class-type-substitution.rs | 37 ---- src/test/run-pass/cci_borrow.rs | 3 +- src/test/run-pass/classes-self-referential.rs | 4 +- src/test/run-pass/cleanup-copy-mode.rs | 21 --- .../crate-method-reexport-grrrrrrr.rs | 4 +- src/test/run-pass/cycle-collection.rs | 27 --- src/test/run-pass/deref-lval.rs | 7 +- src/test/run-pass/deref.rs | 4 +- src/test/run-pass/double-unbox.rs | 21 --- src/test/run-pass/drop-on-empty-block-exit.rs | 6 +- src/test/run-pass/enum-null-pointer-opt.rs | 4 +- .../enum-nullable-simplifycfg-misopt.rs | 6 +- src/test/run-pass/evec-internal-boxes.rs | 22 --- src/test/run-pass/export-non-interference.rs | 4 +- src/test/run-pass/expr-block-box.rs | 14 -- src/test/run-pass/expr-block-generic-box1.rs | 30 ---- src/test/run-pass/expr-block-generic-box2.rs | 26 --- src/test/run-pass/expr-block-ref.rs | 15 -- src/test/run-pass/expr-elseif-ref.rs | 20 --- src/test/run-pass/expr-elseif-ref2.rs | 23 --- src/test/run-pass/expr-if-box.rs | 25 --- src/test/run-pass/expr-if-generic-box1.rs | 26 --- src/test/run-pass/expr-if-generic-box2.rs | 26 --- src/test/run-pass/expr-match-box.rs | 26 --- src/test/run-pass/expr-match-generic-box1.rs | 26 --- src/test/run-pass/expr-match-generic-box2.rs | 26 --- src/test/run-pass/exterior.rs | 5 +- src/test/run-pass/fail-during-tld-destroy.rs | 30 +--- src/test/run-pass/gc-vec.rs | 22 --- src/test/run-pass/generic-alias-box.rs | 23 --- src/test/run-pass/generic-box.rs | 21 --- src/test/run-pass/generic-drop-glue.rs | 18 -- src/test/run-pass/generic-exterior-box.rs | 22 --- src/test/run-pass/generic-fn-box.rs | 18 -- src/test/run-pass/generic-ivec.rs | 15 -- src/test/run-pass/generic-recursive-tag.rs | 12 +- src/test/run-pass/generic-tag.rs | 6 +- src/test/run-pass/ifmt.rs | 2 - src/test/run-pass/init-res-into-things.rs | 42 ++--- src/test/run-pass/issue-14082.rs | 9 +- src/test/run-pass/issue-2631-b.rs | 7 +- src/test/run-pass/issue-2708.rs | 4 +- src/test/run-pass/issue-2735-2.rs | 11 +- src/test/run-pass/issue-2735-3.rs | 11 +- src/test/run-pass/issue-3012-2.rs | 3 +- src/test/run-pass/issue-3121.rs | 6 +- src/test/run-pass/issue-3447.rs | 5 +- src/test/run-pass/issue-3556.rs | 35 ++-- src/test/run-pass/issue-5884.rs | 4 +- src/test/run-pass/issue-6117.rs | 4 +- src/test/run-pass/issue-8898.rs | 4 - src/test/run-pass/issue-8983.rs | 20 --- src/test/run-pass/issue-979.rs | 11 +- src/test/run-pass/issue-980.rs | 29 --- src/test/run-pass/leak-box-as-tydesc.rs | 16 -- src/test/run-pass/leak-tag-copy.rs | 18 -- src/test/run-pass/list.rs | 6 +- src/test/run-pass/mlist.rs | 16 -- src/test/run-pass/move-1.rs | 30 ---- src/test/run-pass/move-2.rs | 4 +- src/test/run-pass/move-3.rs | 29 --- src/test/run-pass/move-4.rs | 6 +- src/test/run-pass/move-arg-2.rs | 8 +- src/test/run-pass/mutable-vec-drop.rs | 23 --- src/test/run-pass/mutual-recursion-group.rs | 8 +- src/test/run-pass/new-box-syntax.rs | 9 +- src/test/run-pass/newtype-struct-drop-run.rs | 7 +- .../nullable-pointer-iotareduction.rs | 2 - src/test/run-pass/nullable-pointer-size.rs | 2 - ...cts-owned-object-borrowed-method-header.rs | 42 ----- src/test/run-pass/option-unwrap.rs | 10 +- src/test/run-pass/output-slot-variants.rs | 22 ++- src/test/run-pass/packed-struct-size.rs | 5 +- src/test/run-pass/packed-tuple-struct-size.rs | 5 +- src/test/run-pass/pass-by-copy.rs | 26 --- src/test/run-pass/rcvr-borrowed-to-region.rs | 11 -- src/test/run-pass/regions-borrow-at.rs | 4 +- .../run-pass/regions-escape-into-other-fn.rs | 4 +- ...gions-infer-borrow-scope-within-loop-ok.rs | 4 +- .../run-pass/regions-infer-borrow-scope.rs | 4 +- .../run-pass/resource-assign-is-not-copy.rs | 16 +- src/test/run-pass/resource-destruct.rs | 13 +- src/test/run-pass/resource-in-struct.rs | 11 +- .../run-pass/shape_intrinsic_tag_then_rec.rs | 26 ++- src/test/run-pass/terminate-in-initializer.rs | 11 +- src/test/run-pass/trait-cast.rs | 74 -------- src/test/run-pass/type-param-constraints.rs | 6 - .../run-pass/typeclasses-eq-example-static.rs | 38 ++-- src/test/run-pass/typeclasses-eq-example.rs | 40 ++--- src/test/run-pass/uniq-cc-generic.rs | 44 ----- src/test/run-pass/uniq-cc.rs | 40 ----- src/test/run-pass/unique-assign-generic.rs | 4 - src/test/run-pass/unwind-box.rs | 22 --- src/test/run-pass/unwind-resource2.rs | 38 ---- src/test/run-pass/vec-drop.rs | 23 --- src/test/run-pass/vec-slice-drop.rs | 11 +- src/test/run-pass/weird-exprs.rs | 5 +- 206 files changed, 322 insertions(+), 3702 deletions(-) delete mode 100644 src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs delete mode 100644 src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs delete mode 100644 src/test/compile-fail/borrowck-preserve-box-in-field.rs delete mode 100644 src/test/compile-fail/borrowck-preserve-box-in-uniq.rs delete mode 100644 src/test/compile-fail/borrowck-preserve-box.rs delete mode 100644 src/test/compile-fail/borrowck-preserve-cond-box.rs delete mode 100644 src/test/compile-fail/borrowck-preserve-expl-deref.rs delete mode 100644 src/test/compile-fail/box-static-bound.rs delete mode 100644 src/test/compile-fail/lint-heap-memory.rs delete mode 100644 src/test/compile-fail/lint-managed-heap-memory.rs delete mode 100644 src/test/compile-fail/new-box-syntax-bad.rs delete mode 100644 src/test/compile-fail/pinned-deep-copy.rs delete mode 100644 src/test/compile-fail/regions-appearance-constraint.rs delete mode 100644 src/test/debuginfo/borrowed-managed-basic.rs delete mode 100644 src/test/debuginfo/managed-enum.rs delete mode 100644 src/test/debuginfo/managed-pointer-within-unique-vec.rs delete mode 100644 src/test/debuginfo/managed-pointer-within-unique.rs delete mode 100644 src/test/run-fail/issue-2272.rs delete mode 100644 src/test/run-fail/unwind-assert.rs delete mode 100644 src/test/run-fail/unwind-box-fn-unique.rs delete mode 100644 src/test/run-fail/unwind-box-res.rs delete mode 100644 src/test/run-fail/unwind-box-str.rs delete mode 100644 src/test/run-fail/unwind-box-unique-unique.rs delete mode 100644 src/test/run-fail/unwind-box-unique.rs delete mode 100644 src/test/run-fail/unwind-box-vec.rs delete mode 100644 src/test/run-fail/unwind-box.rs delete mode 100644 src/test/run-fail/unwind-fail.rs delete mode 100644 src/test/run-fail/unwind-initializer-indirect.rs delete mode 100644 src/test/run-fail/unwind-initializer.rs delete mode 100644 src/test/run-fail/unwind-iter.rs delete mode 100644 src/test/run-fail/unwind-iter2.rs delete mode 100644 src/test/run-fail/unwind-lambda.rs delete mode 100644 src/test/run-fail/unwind-match.rs delete mode 100644 src/test/run-fail/unwind-misc-1.rs delete mode 100644 src/test/run-fail/unwind-move.rs delete mode 100644 src/test/run-fail/unwind-nested.rs delete mode 100644 src/test/run-fail/unwind-partial-box.rs delete mode 100644 src/test/run-fail/unwind-partial-unique.rs delete mode 100644 src/test/run-fail/unwind-partial-vec.rs delete mode 100644 src/test/run-fail/unwind-resource-fail.rs delete mode 100644 src/test/run-fail/unwind-resource-fail2.rs delete mode 100644 src/test/run-fail/unwind-resource-fail3.rs delete mode 100644 src/test/run-fail/unwind-stacked.rs delete mode 100644 src/test/run-fail/unwind-tup.rs delete mode 100644 src/test/run-fail/unwind-tup2.rs delete mode 100644 src/test/run-fail/unwind-uninitialized.rs delete mode 100644 src/test/run-pass/borrowck-preserve-box-in-moved-value.rs delete mode 100644 src/test/run-pass/borrowck-root-while-cond-2.rs delete mode 100644 src/test/run-pass/borrowck-root-while-cond.rs delete mode 100644 src/test/run-pass/box-compare.rs delete mode 100644 src/test/run-pass/box-in-tup.rs delete mode 100644 src/test/run-pass/box-inside-if.rs delete mode 100644 src/test/run-pass/box-inside-if2.rs delete mode 100644 src/test/run-pass/box-pattern.rs delete mode 100644 src/test/run-pass/box-unbox.rs delete mode 100644 src/test/run-pass/box.rs delete mode 100644 src/test/run-pass/boxed-class-type-substitution.rs delete mode 100644 src/test/run-pass/cleanup-copy-mode.rs delete mode 100644 src/test/run-pass/cycle-collection.rs delete mode 100644 src/test/run-pass/double-unbox.rs delete mode 100644 src/test/run-pass/evec-internal-boxes.rs delete mode 100644 src/test/run-pass/expr-block-box.rs delete mode 100644 src/test/run-pass/expr-block-generic-box1.rs delete mode 100644 src/test/run-pass/expr-block-generic-box2.rs delete mode 100644 src/test/run-pass/expr-block-ref.rs delete mode 100644 src/test/run-pass/expr-elseif-ref.rs delete mode 100644 src/test/run-pass/expr-elseif-ref2.rs delete mode 100644 src/test/run-pass/expr-if-box.rs delete mode 100644 src/test/run-pass/expr-if-generic-box1.rs delete mode 100644 src/test/run-pass/expr-if-generic-box2.rs delete mode 100644 src/test/run-pass/expr-match-box.rs delete mode 100644 src/test/run-pass/expr-match-generic-box1.rs delete mode 100644 src/test/run-pass/expr-match-generic-box2.rs delete mode 100644 src/test/run-pass/gc-vec.rs delete mode 100644 src/test/run-pass/generic-alias-box.rs delete mode 100644 src/test/run-pass/generic-box.rs delete mode 100644 src/test/run-pass/generic-drop-glue.rs delete mode 100644 src/test/run-pass/generic-exterior-box.rs delete mode 100644 src/test/run-pass/generic-fn-box.rs delete mode 100644 src/test/run-pass/generic-ivec.rs delete mode 100644 src/test/run-pass/issue-8983.rs delete mode 100644 src/test/run-pass/issue-980.rs delete mode 100644 src/test/run-pass/leak-box-as-tydesc.rs delete mode 100644 src/test/run-pass/leak-tag-copy.rs delete mode 100644 src/test/run-pass/mlist.rs delete mode 100644 src/test/run-pass/move-1.rs delete mode 100644 src/test/run-pass/move-3.rs delete mode 100644 src/test/run-pass/mutable-vec-drop.rs delete mode 100644 src/test/run-pass/objects-owned-object-borrowed-method-header.rs delete mode 100644 src/test/run-pass/pass-by-copy.rs delete mode 100644 src/test/run-pass/trait-cast.rs delete mode 100644 src/test/run-pass/uniq-cc-generic.rs delete mode 100644 src/test/run-pass/uniq-cc.rs delete mode 100644 src/test/run-pass/unwind-box.rs delete mode 100644 src/test/run-pass/unwind-resource2.rs delete mode 100644 src/test/run-pass/vec-drop.rs diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index ec19844a24a..049bf4eb1b0 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -541,14 +541,6 @@ mod tests { assert!(y.upgrade().is_none()); } - #[test] - fn gc_inside() { - // see issue #11532 - use std::gc::GC; - let a = Rc::new(RefCell::new(box(GC) 1i)); - assert!(a.try_borrow_mut().is_some()); - } - #[test] fn weak_self_cyclic() { struct Cycle { diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 0e1c39535be..c9c824ac9ce 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -532,7 +532,6 @@ impl fmt::Show for RingBuf { mod tests { use std::fmt::Show; use std::prelude::*; - use std::gc::{GC, Gc}; use std::hash; use test::Bencher; use test; @@ -587,43 +586,6 @@ mod tests { assert_eq!(*d.get(3), 4); } - #[test] - #[allow(deprecated)] - fn test_boxes() { - let a: Gc = box(GC) 5; - let b: Gc = box(GC) 72; - let c: Gc = box(GC) 64; - let d: Gc = box(GC) 175; - - let mut deq = RingBuf::new(); - assert_eq!(deq.len(), 0); - deq.push_front(a); - deq.push_front(b); - deq.push(c); - assert_eq!(deq.len(), 3); - deq.push(d); - assert_eq!(deq.len(), 4); - assert_eq!(deq.front(), Some(&b)); - assert_eq!(deq.back(), Some(&d)); - assert_eq!(deq.pop_front(), Some(b)); - assert_eq!(deq.pop(), Some(d)); - assert_eq!(deq.pop(), Some(c)); - assert_eq!(deq.pop(), Some(a)); - assert_eq!(deq.len(), 0); - deq.push(c); - assert_eq!(deq.len(), 1); - deq.push_front(b); - assert_eq!(deq.len(), 2); - deq.push(d); - assert_eq!(deq.len(), 3); - deq.push_front(a); - assert_eq!(deq.len(), 4); - assert_eq!(*deq.get(0), a); - assert_eq!(*deq.get(1), b); - assert_eq!(*deq.get(2), c); - assert_eq!(*deq.get(3), d); - } - #[cfg(test)] fn test_parameterized(a: T, b: T, c: T, d: T) { let mut deq = RingBuf::new(); @@ -755,12 +717,6 @@ mod tests { test_parameterized::(5, 72, 64, 175); } - #[test] - fn test_param_at_int() { - test_parameterized::>(box(GC) 5, box(GC) 72, - box(GC) 64, box(GC) 175); - } - #[test] fn test_param_taggy() { test_parameterized::(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42)); diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index e84c8947967..9e47142478e 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -529,9 +529,8 @@ fn test_rposition() { #[test] #[should_fail] fn test_rposition_fail() { - use std::gc::GC; - let v = [(box 0i, box(GC) 0i), (box 0i, box(GC) 0i), - (box 0i, box(GC) 0i), (box 0i, box(GC) 0i)]; + let v = [(box 0i, box 0i), (box 0i, box 0i), + (box 0i, box 0i), (box 0i, box 0i)]; let mut i = 0i; v.iter().rposition(|_elt| { if i == 2 { diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs index 98c01000cb0..e27816c8165 100644 --- a/src/libdebug/repr.rs +++ b/src/libdebug/repr.rs @@ -572,7 +572,6 @@ fn test_repr() { use std::io::stdio::println; use std::char::is_alphabetic; use std::mem::swap; - use std::gc::GC; fn exact_test(t: &T, e:&str) { let mut m = io::MemWriter::new(); @@ -587,7 +586,6 @@ fn test_repr() { exact_test(&1.234f64, "1.234f64"); exact_test(&("hello"), "\"hello\""); - exact_test(&(box(GC) 10i), "box(GC) 10"); exact_test(&(box 10i), "box 10"); exact_test(&(&10i), "&10"); let mut x = 10i; @@ -601,8 +599,6 @@ fn test_repr() { "&[\"hi\", \"there\"]"); exact_test(&(P{a:10, b:1.234}), "repr::P{a: 10, b: 1.234f64}"); - exact_test(&(box(GC) P{a:10, b:1.234}), - "box(GC) repr::P{a: 10, b: 1.234f64}"); exact_test(&(box P{a:10, b:1.234}), "box repr::P{a: 10, b: 1.234f64}"); diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index e7ce5b7dca8..fcef5981f0a 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -411,7 +411,6 @@ mod tests { extern crate test; use std::prelude::*; - use std::gc::{Gc, GC}; use super::*; use std::task; @@ -467,11 +466,11 @@ mod tests { #[test] fn test_tls_multiple_types() { static str_key: Key = &KeyValueKey; - static box_key: Key> = &KeyValueKey; + static box_key: Key> = &KeyValueKey; static int_key: Key = &KeyValueKey; task::spawn(proc() { str_key.replace(Some("string data".to_string())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 0)); int_key.replace(Some(42)); }); } @@ -479,13 +478,13 @@ mod tests { #[test] fn test_tls_overwrite_multiple_types() { static str_key: Key = &KeyValueKey; - static box_key: Key> = &KeyValueKey; + static box_key: Key> = &KeyValueKey; static int_key: Key = &KeyValueKey; task::spawn(proc() { str_key.replace(Some("string data".to_string())); str_key.replace(Some("string data 2".to_string())); - box_key.replace(Some(box(GC) ())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 0)); + box_key.replace(Some(box 1)); int_key.replace(Some(42)); // This could cause a segfault if overwriting-destruction is done // with the crazy polymorphic transmute rather than the provided @@ -498,13 +497,13 @@ mod tests { #[should_fail] fn test_tls_cleanup_on_failure() { static str_key: Key = &KeyValueKey; - static box_key: Key> = &KeyValueKey; + static box_key: Key> = &KeyValueKey; static int_key: Key = &KeyValueKey; str_key.replace(Some("parent data".to_string())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 0)); task::spawn(proc() { str_key.replace(Some("string data".to_string())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 2)); int_key.replace(Some(42)); fail!(); }); diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index 9e88d05884c..ca5f76cf0d4 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -554,23 +554,14 @@ mod test { use super::*; use std::prelude::*; use std::task; - use std::gc::{Gc, GC}; - - #[test] - fn local_heap() { - let a = box(GC) 5i; - let b = a; - assert!(*a == 5); - assert!(*b == 5); - } #[test] fn tls() { - local_data_key!(key: Gc) - key.replace(Some(box(GC) "data".to_string())); + local_data_key!(key: String) + key.replace(Some("data".to_string())); assert_eq!(key.get().unwrap().as_slice(), "data"); - local_data_key!(key2: Gc) - key2.replace(Some(box(GC) "data".to_string())); + local_data_key!(key2: String) + key2.replace(Some("data".to_string())); assert_eq!(key2.get().unwrap().as_slice(), "data"); } @@ -605,23 +596,6 @@ mod test { assert!(rx.recv() == 10); } - #[test] - fn heap_cycles() { - use std::cell::RefCell; - - struct List { - next: Option>>, - } - - let a = box(GC) RefCell::new(List { next: None }); - let b = box(GC) RefCell::new(List { next: Some(a) }); - - { - let mut a = a.borrow_mut(); - a.next = Some(b); - } - } - #[test] #[should_fail] fn test_begin_unwind() { diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index b097e688b42..bbaf7991fd3 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -10,7 +10,6 @@ use std::cell::RefCell; -use std::gc::{Gc, GC}; pub struct Entry { key: A, @@ -19,7 +18,7 @@ pub struct Entry { pub struct alist { eq_fn: extern "Rust" fn(A,A) -> bool, - data: Gc>>>, + data: Box>>>, } pub fn alist_add(lst: &alist, k: A, v: B) { @@ -47,7 +46,7 @@ pub fn new_int_alist() -> alist { fn eq_int(a: int, b: int) -> bool { a == b } return alist { eq_fn: eq_int, - data: box(GC) RefCell::new(Vec::new()), + data: box RefCell::new(Vec::new()), }; } @@ -57,6 +56,6 @@ pub fn new_int_alist_2() -> alist { fn eq_int(a: int, b: int) -> bool { a == b } return alist { eq_fn: eq_int, - data: box(GC) RefCell::new(Vec::new()), + data: box RefCell::new(Vec::new()), }; } diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs index e9a24900176..5e2a04001b5 100644 --- a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs @@ -27,9 +27,8 @@ pub mod name_pool { pub mod rust { pub use name_pool::add; - use std::gc::Gc; - pub type rt = Gc<()>; + pub type rt = Box<()>; pub trait cx { fn cx(&self); diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 61c7d3f87df..3bedbd9089c 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -13,9 +13,9 @@ use std::cell::RefCell; use std::collections::HashMap; -use std::gc::Gc; +use std::rc::Rc; -pub type header_map = HashMap>>>>; +pub type header_map = HashMap>>>>; // the unused ty param is necessary so this gets monomorphized pub fn request(req: &header_map) { diff --git a/src/test/auxiliary/issue-5521.rs b/src/test/auxiliary/issue-5521.rs index 5d56db314b2..d9d393cc749 100644 --- a/src/test/auxiliary/issue-5521.rs +++ b/src/test/auxiliary/issue-5521.rs @@ -10,7 +10,6 @@ use std::collections::HashMap; -use std::gc::Gc; -pub type map = Gc>; +pub type map = Box>; diff --git a/src/test/auxiliary/issue13507.rs b/src/test/auxiliary/issue13507.rs index ee7787d6fcc..961dad00091 100644 --- a/src/test/auxiliary/issue13507.rs +++ b/src/test/auxiliary/issue13507.rs @@ -56,8 +56,6 @@ pub mod testtypes { VarB(uint, uint) } - // Skipping ty_box - // Tests ty_uniq (of u8) pub type FooUniq = Box; diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 93b22edbf03..6729373296b 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -10,18 +10,15 @@ #![feature(unsafe_destructor)] -extern crate collections; extern crate time; use time::precise_time_s; use std::os; use std::task; -use std::vec; -use std::gc::{Gc, GC}; #[deriving(Clone)] enum List { - Nil, Cons(T, Gc>) + Nil, Cons(T, Box>) } enum UniqueList { @@ -53,15 +50,13 @@ type nillist = List<()>; // Filled with things that have to be unwound struct State { - managed: Gc, unique: Box, - tuple: (Gc, Box), - vec: Vec>, + vec: Vec>, res: r } struct r { - _l: Gc, + _l: Box, } #[unsafe_destructor] @@ -69,7 +64,7 @@ impl Drop for r { fn drop(&mut self) {} } -fn r(l: Gc) -> r { +fn r(l: Box) -> r { r { _l: l } @@ -85,22 +80,17 @@ fn recurse_or_fail(depth: int, st: Option) { let st = match st { None => { State { - managed: box(GC) Nil, unique: box Nil, - tuple: (box(GC) Nil, box Nil), - vec: vec!(box(GC) Nil), - res: r(box(GC) Nil) + vec: vec!(box Nil), + res: r(box Nil) } } Some(st) => { State { - managed: box(GC) Cons((), st.managed), - unique: box Cons((), box(GC) *st.unique), - tuple: (box(GC) Cons((), st.tuple.ref0().clone()), - box Cons((), box(GC) *st.tuple.ref1().clone())), + unique: box Cons((), box *st.unique), vec: st.vec.clone().append( - &[box(GC) Cons((), *st.vec.last().unwrap())]), - res: r(box(GC) Cons((), st.res._l)) + &[box Cons((), *st.vec.last().unwrap())]), + res: r(box Cons((), st.res._l)) } } }; diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index 276c830cf5d..7aa3b30ce49 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -8,30 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -extern crate debug; - -use std::gc::{Gc, GC}; - struct clam { - x: Gc, - y: Gc, + x: Box, + y: Box, } struct fish { - a: Gc, + a: Box, } fn main() { - let a: clam = clam{x: box(GC) 1, y: box(GC) 2}; - let b: clam = clam{x: box(GC) 10, y: box(GC) 20}; - let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Gc` - println!("{:?}", z); + let a: clam = clam{x: box 1, y: box 2}; + let b: clam = clam{x: box 10, y: box 20}; + let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box` + println!("{}", z); assert_eq!(z, 21); - let forty: fish = fish{a: box(GC) 40}; - let two: fish = fish{a: box(GC) 2}; + let forty: fish = fish{a: box 40}; + let two: fish = fish{a: box 2}; let answer: int = forty.a + two.a; - //~^ ERROR binary operation `+` cannot be applied to type `Gc` - println!("{:?}", answer); + //~^ ERROR binary operation `+` cannot be applied to type `Box` + println!("{}", answer); assert_eq!(answer, 42); } diff --git a/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs b/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs deleted file mode 100644 index 91eb20d19ed..00000000000 --- a/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -struct A; - -impl A { - fn foo(&mut self) { - } -} - -pub fn main() { - let a = box(GC) A; - a.foo(); - //~^ ERROR cannot borrow immutable dereference of `Gc` `*a` as mutable -} diff --git a/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs b/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs deleted file mode 100644 index a8a79056fb1..00000000000 --- a/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Verify that managed pointers scope is treated like owned pointers. -// regression test for #11586 - - -use std::gc::{GC, Gc}; - -fn foo(x: &Gc) -> &int { - match x { - &ref y => { - &**y // Do not expect an error here - } - } -} - -fn bar() { - let a = 3i; - let mut y = &a; - if true { - let x = box(GC) 3i; - y = &*x; //~ ERROR `*x` does not live long enough - } -} - -fn main() {} diff --git a/src/test/compile-fail/borrowck-preserve-box-in-field.rs b/src/test/compile-fail/borrowck-preserve-box-in-field.rs deleted file mode 100644 index ad1ac3cc15e..00000000000 --- a/src/test/compile-fail/borrowck-preserve-box-in-field.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -struct F { f: Box } - -pub fn main() { - let mut x = box(GC) F {f: box 3}; - borrow(&*x.f, |b_x| { - //~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable - assert_eq!(*b_x, 3); - assert_eq!(&(*x.f) as *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - x = box(GC) F {f: box 4}; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x.f) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs b/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs deleted file mode 100644 index ec52f058836..00000000000 --- a/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -struct F { f: Box } - -pub fn main() { - let mut x = box box(GC) F{f: box 3}; - borrow(&*x.f, |b_x| { - //~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable - assert_eq!(*b_x, 3); - assert_eq!(&(*x.f) as *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - *x = box(GC) F{f: box 4}; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x.f) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/borrowck-preserve-box.rs b/src/test/compile-fail/borrowck-preserve-box.rs deleted file mode 100644 index 5aff482a323..00000000000 --- a/src/test/compile-fail/borrowck-preserve-box.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -pub fn main() { - let mut x = box(GC) 3; - borrow(&*x, |b_x| { - //~^ ERROR cannot borrow `x` as mutable because `*x` is also borrowed as immutable - assert_eq!(*b_x, 3); - assert_eq!(&(*x) as *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - x = box(GC) 22; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/borrowck-preserve-cond-box.rs b/src/test/compile-fail/borrowck-preserve-cond-box.rs deleted file mode 100644 index 6c3c340b97a..00000000000 --- a/src/test/compile-fail/borrowck-preserve-cond-box.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn testfn(cond: bool) { - let mut x = box(GC) 3i; - let mut y = box(GC) 4i; - - // borrow x and y - let r_x = &*x; - let r_y = &*y; - let mut r = r_x; - let mut exp = 3; - - if cond { - r = r_y; - exp = 4; - } - - println!("*r = {}, exp = {}", *r, exp); - assert_eq!(*r, exp); - - x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed - y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed - - println!("*r = {}, exp = {}", *r, exp); - assert_eq!(*r, exp); - assert_eq!(x, box(GC) 5i); - assert_eq!(y, box(GC) 6i); -} - -pub fn main() { - testfn(true); - testfn(false); -} diff --git a/src/test/compile-fail/borrowck-preserve-expl-deref.rs b/src/test/compile-fail/borrowck-preserve-expl-deref.rs deleted file mode 100644 index 2ad042c69c3..00000000000 --- a/src/test/compile-fail/borrowck-preserve-expl-deref.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -struct F { f: Box } - -pub fn main() { - let mut x = box(GC) F {f: box 3}; - borrow(&*(*x).f, |b_x| { - //~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable - assert_eq!(*b_x, 3); - assert_eq!(&(*x.f) as *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - x = box(GC) F {f: box 4}; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x.f) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/box-static-bound.rs b/src/test/compile-fail/box-static-bound.rs deleted file mode 100644 index 29ee79b0079..00000000000 --- a/src/test/compile-fail/box-static-bound.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn f(x: T) -> Gc { - box(GC) x //~ ERROR the parameter type `T` may not live long enough -} - -fn g(x: T) -> Gc { - box(GC) x // ok -} - -fn main() {} diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs index 3e67419843c..e29be22ca9a 100644 --- a/src/test/compile-fail/check-static-values-constraints.rs +++ b/src/test/compile-fail/check-static-values-constraints.rs @@ -11,7 +11,6 @@ // Verifies all possible restrictions for static items values. use std::kinds::marker; -use std::gc::{Gc, GC}; struct WithDtor; @@ -124,9 +123,6 @@ static STATIC16: (&'static Box, &'static Box) = static mut STATIC17: SafeEnum = Variant1; //~^ ERROR mutable static items are not allowed to have destructors -static STATIC18: Gc = box(GC) SafeStruct{field1: Variant1, field2: Variant2(0)}; -//~^ ERROR static items are not allowed to have custom pointers - static STATIC19: Box = box 3; //~^ ERROR static items are not allowed to have custom pointers diff --git a/src/test/compile-fail/core-tls-store-pointer.rs b/src/test/compile-fail/core-tls-store-pointer.rs index 06079a5487f..d77c552be03 100644 --- a/src/test/compile-fail/core-tls-store-pointer.rs +++ b/src/test/compile-fail/core-tls-store-pointer.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Testing that we can't store a reference it task-local storage +// Testing that we can't store a reference in task-local storage -use std::gc::{GC, Gc}; - -local_data_key!(key: Gc<&int>) +local_data_key!(key: Box<&int>) //~^ ERROR missing lifetime specifier fn main() {} diff --git a/src/test/compile-fail/issue-14915.rs b/src/test/compile-fail/issue-14915.rs index 4512eb3f70a..8cbbfb7b83a 100644 --- a/src/test/compile-fail/issue-14915.rs +++ b/src/test/compile-fail/issue-14915.rs @@ -8,12 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::gc::{GC,Gc}; - fn main() { let x: Box = box 0; - let y: Gc = box (GC) 0; println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box` - println!("{}", y + 1); //~ ERROR binary operation `+` cannot be applied to type `Gc` } diff --git a/src/test/compile-fail/issue-2063-resource.rs b/src/test/compile-fail/issue-2063-resource.rs index 577ac480f60..30cf7ee7d88 100644 --- a/src/test/compile-fail/issue-2063-resource.rs +++ b/src/test/compile-fail/issue-2063-resource.rs @@ -9,17 +9,14 @@ // except according to those terms. -use std::gc::Gc; - // test that autoderef of a type like this does not // cause compiler to loop. Note that no instances // of such a type could ever be constructed. -struct t { //~ ERROR this type cannot be instantiated - x: x, +struct S { //~ ERROR this type cannot be instantiated + x: X, to_str: (), } -struct x(Gc); //~ ERROR this type cannot be instantiated +struct X(Box); //~ ERROR this type cannot be instantiated -fn main() { -} +fn main() {} diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index d3bd17a7742..cccf730095b 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -8,17 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use std::gc::Gc; - -struct P { child: Option> } +struct P { child: Option> } trait PTrait { - fn getChildOption(&self) -> Option>; + fn getChildOption(&self) -> Option>; } impl PTrait for P { - fn getChildOption(&self) -> Option> { - static childVal: Gc

= self.child.get(); + fn getChildOption(&self) -> Option> { + static childVal: Box

= self.child.get(); //~^ ERROR attempt to use a non-constant value in a constant fail!(); } diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs index 9003578a0bb..73d42aa0de1 100644 --- a/src/test/compile-fail/issue-3763.rs +++ b/src/test/compile-fail/issue-3763.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - mod my_mod { pub struct MyStruct { priv_field: int @@ -29,11 +27,8 @@ fn main() { //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private let _woohoo = (box my_struct).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private - let _woohoo = (box(GC) my_struct).priv_field; - //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private (&my_struct).happyfun(); //~ ERROR method `happyfun` is private (box my_struct).happyfun(); //~ ERROR method `happyfun` is private - (box(GC) my_struct).happyfun(); //~ ERROR method `happyfun` is private let nope = my_struct.priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private } diff --git a/src/test/compile-fail/issue-7061.rs b/src/test/compile-fail/issue-7061.rs index a9e9416beb3..c6869c44057 100644 --- a/src/test/compile-fail/issue-7061.rs +++ b/src/test/compile-fail/issue-7061.rs @@ -8,14 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use std::gc::Gc; - struct BarStruct; impl<'a> BarStruct { - fn foo(&'a mut self) -> Gc { self } - //~^ ERROR: error: mismatched types: expected `Gc`, found `&'a mut BarStruct + fn foo(&'a mut self) -> Box { self } + //~^ ERROR: error: mismatched types: expected `Box`, found `&'a mut BarStruct } fn main() {} diff --git a/src/test/compile-fail/issue-7364.rs b/src/test/compile-fail/issue-7364.rs index 1c0295974c9..e29b8bc04d8 100644 --- a/src/test/compile-fail/issue-7364.rs +++ b/src/test/compile-fail/issue-7364.rs @@ -10,10 +10,9 @@ use std::cell::RefCell; -use std::gc::{Gc, GC}; // Regresion test for issue 7364 -static managed: Gc> = box(GC) RefCell::new(0); +static boxed: Box> = box RefCell::new(0); //~^ ERROR static items are not allowed to have custom pointers fn main() { } diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index 3524d11d184..499144698fb 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -12,7 +12,6 @@ use std::rc::Rc; -use std::gc::Gc; fn assert_copy() { } trait Dummy { } @@ -76,8 +75,7 @@ fn test<'a,T,U:Copy>(_: &'a int) { // structs containing non-POD are not ok assert_copy::(); //~ ERROR `core::kinds::Copy` is not implemented - // managed or ref counted types are not ok - assert_copy::>(); //~ ERROR `core::kinds::Copy` is not implemented + // ref counted types are not ok assert_copy::>(); //~ ERROR `core::kinds::Copy` is not implemented } diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs index e50bb8fbede..26b0c5503e3 100644 --- a/src/test/compile-fail/kindck-destructor-owned.rs +++ b/src/test/compile-fail/kindck-destructor-owned.rs @@ -9,10 +9,10 @@ // except according to those terms. -use std::gc::Gc; +use std::rc::Rc; struct Foo { - f: Gc, + f: Rc, } impl Drop for Foo { diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index f292d159982..6ca3f0174bb 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -9,12 +9,12 @@ // except according to those terms. -use std::gc::{Gc, GC}; +use std::rc::Rc; -fn foo(_x: Gc) {} +fn foo(_x: Rc) {} fn main() { - let x = box(GC) 3u; + let x = Rc::new(3u); let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented diff --git a/src/test/compile-fail/lint-heap-memory.rs b/src/test/compile-fail/lint-heap-memory.rs deleted file mode 100644 index 375969ffb52..00000000000 --- a/src/test/compile-fail/lint-heap-memory.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![forbid(heap_memory)] -#![allow(dead_code)] - -use std::gc::{Gc, GC}; - -struct Foo { - x: Gc, //~ ERROR type uses managed -} - -struct Bar { x: Box } //~ ERROR type uses owned - -fn main() { - let _x : Bar = Bar {x : box 10i}; //~ ERROR type uses owned - - box(GC) 2i; //~ ERROR type uses managed - - box 2i; //~ ERROR type uses owned - fn g(_: Box) {} //~ ERROR type uses owned - proc() {}; //~ ERROR type uses owned -} diff --git a/src/test/compile-fail/lint-managed-heap-memory.rs b/src/test/compile-fail/lint-managed-heap-memory.rs deleted file mode 100644 index 0a28242fb1b..00000000000 --- a/src/test/compile-fail/lint-managed-heap-memory.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -#![forbid(managed_heap_memory)] - -use std::gc::{Gc, GC}; - -struct Foo { - x: Gc //~ ERROR type uses managed -} - -fn main() { - let _x : Foo = Foo {x : box(GC) 10}; - //~^ ERROR type uses managed -} diff --git a/src/test/compile-fail/new-box-syntax-bad.rs b/src/test/compile-fail/new-box-syntax-bad.rs deleted file mode 100644 index 602ffe2680b..00000000000 --- a/src/test/compile-fail/new-box-syntax-bad.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -// Tests that the new `box` syntax works with unique pointers and GC pointers. - -use std::gc::{Gc, GC}; -use std::boxed::{Box, HEAP}; - -pub fn main() { - let x: Gc = box(HEAP) 2; //~ ERROR mismatched types - let y: Gc = box(HEAP)(1 + 2); //~ ERROR mismatched types - let z: Box = box(GC)(4 + 5); //~ ERROR mismatched types -} - diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index ddbfbc41eca..83dbd9ac1bf 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -10,14 +10,14 @@ #![feature(unsafe_destructor)] -extern crate debug; - use std::task; -use std::gc::{Gc, GC}; +use std::rc::Rc; -struct Port(Gc); +#[deriving(Show)] +struct Port(Rc); fn main() { + #[deriving(Show)] struct foo { _x: Port<()>, } @@ -33,11 +33,11 @@ fn main() { } } - let x = foo(Port(box(GC) ())); + let x = foo(Port(Rc::new(()))); task::spawn(proc() { let y = x; //~^ ERROR `core::kinds::Send` is not implemented - println!("{:?}", y); + println!("{}", y); }); } diff --git a/src/test/compile-fail/occurs-check-2.rs b/src/test/compile-fail/occurs-check-2.rs index 69c012e0d8e..2765182225f 100644 --- a/src/test/compile-fail/occurs-check-2.rs +++ b/src/test/compile-fail/occurs-check-2.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::gc::GC; fn main() { let f; let g; g = f; - f = box(GC) g; //~ ERROR cyclic type of infinite size + f = box g; //~ ERROR cyclic type of infinite size } diff --git a/src/test/compile-fail/occurs-check.rs b/src/test/compile-fail/occurs-check.rs index a00528616c3..44318b36f4b 100644 --- a/src/test/compile-fail/occurs-check.rs +++ b/src/test/compile-fail/occurs-check.rs @@ -9,9 +9,7 @@ // except according to those terms. -use std::gc::GC; - fn main() { let f; - f = box(GC) f; //~ ERROR cyclic type of infinite size + f = box f; //~ ERROR cyclic type of infinite size } diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs deleted file mode 100644 index 0e8bb40e0ff..00000000000 --- a/src/test/compile-fail/pinned-deep-copy.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unsafe_destructor)] - -extern crate debug; - -use std::cell::Cell; -use std::gc::{Gc, GC}; - -struct r { - i: Gc>, -} - -#[unsafe_destructor] -impl Drop for r { - fn drop(&mut self) { - unsafe { - self.i.set(self.i.get() + 1); - } - } -} - -fn r(i: Gc>) -> r { - r { - i: i - } -} - -struct A { - y: r, -} - -fn main() { - let i = box(GC) Cell::new(0); - { - // Can't do this copy - let x = box box box A {y: r(i)}; - let _z = x.clone(); //~ ERROR not implemented - println!("{:?}", x); - } - println!("{:?}", *i); -} diff --git a/src/test/compile-fail/regions-appearance-constraint.rs b/src/test/compile-fail/regions-appearance-constraint.rs deleted file mode 100644 index 2c068052c54..00000000000 --- a/src/test/compile-fail/regions-appearance-constraint.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test no-special rooting is used for managed boxes - - -use std::gc::GC; - -fn testfn(cond: bool) { - let mut x = box(GC) 3i; - let mut y = box(GC) 4i; - - let mut a = &*x; - - let mut exp = 3i; - if cond { - a = &*y; - - exp = 4; - } - - x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed - y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed - assert_eq!(*a, exp); - assert_eq!(x, box(GC) 5i); - assert_eq!(y, box(GC) 6i); -} - -pub fn main() {} diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs index fc513b91f89..b710578969b 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - struct point { x: int, y: int, @@ -20,7 +18,7 @@ fn x_coord<'r>(p: &'r point) -> &'r int { return &p.x; } -fn foo<'a>(p: Gc) -> &'a int { +fn foo<'a>(p: Box) -> &'a int { let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough assert_eq!(*xc, 3); return xc; diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index 623b8e6319f..cf1fa2cfc4c 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -9,11 +9,9 @@ // except according to those terms. -use std::gc::Gc; - fn borrow(x: &T) -> &T {x} -fn foo(cond: || -> bool, make_box: || -> Gc) { +fn foo(cond: || -> bool, make_box: || -> Box) { let mut y: ∫ loop { let x = make_box(); diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index e862b36dcd1..f93907f5e5c 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -12,27 +12,25 @@ // Check that we correctly infer that b and c must be region // parameterized because they reference a which requires a region. -use std::gc::Gc; - type a<'a> = &'a int; -type b<'a> = Gc>; +type b<'a> = Box>; struct c<'a> { - f: Gc> + f: Box> } trait set_f<'a> { - fn set_f_ok(&mut self, b: Gc>); - fn set_f_bad(&mut self, b: Gc); + fn set_f_ok(&mut self, b: Box>); + fn set_f_bad(&mut self, b: Box); } impl<'a> set_f<'a> for c<'a> { - fn set_f_ok(&mut self, b: Gc>) { + fn set_f_ok(&mut self, b: Box>) { self.f = b; } - fn set_f_bad(&mut self, b: Gc) { - self.f = b; //~ ERROR mismatched types: expected `Gc>`, found `Gc>` + fn set_f_bad(&mut self, b: Box) { + self.f = b; //~ ERROR mismatched types: expected `Box>`, found `Box>` } } diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index 2cb1f462e1d..1e5a5ecc08e 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -9,12 +9,10 @@ // except according to those terms. -use std::gc::GC; - fn f(_: T) {} fn main() { - let x = box(GC) 3i; + let x = box 3i; f(x); let x = &3i; //~ ERROR borrowed value does not live long enough f(x); diff --git a/src/test/compile-fail/struct-field-assignability.rs b/src/test/compile-fail/struct-field-assignability.rs index 557341fd4f0..2c3d48e9bf7 100644 --- a/src/test/compile-fail/struct-field-assignability.rs +++ b/src/test/compile-fail/struct-field-assignability.rs @@ -11,13 +11,11 @@ // except according to those terms. -use std::gc::{Gc, GC}; - struct Foo<'a> { x: &'a int } pub fn main() { - let f = Foo { x: &*(box(GC) 3) }; //~ ERROR borrowed value does not live long enough + let f = Foo { x: &*(box 3) }; //~ ERROR borrowed value does not live long enough assert_eq!(*f.x, 3); } diff --git a/src/test/compile-fail/terr-sorts.rs b/src/test/compile-fail/terr-sorts.rs index 0817d7c610a..53ebe1f9b5b 100644 --- a/src/test/compile-fail/terr-sorts.rs +++ b/src/test/compile-fail/terr-sorts.rs @@ -9,18 +9,16 @@ // except according to those terms. -use std::gc::Gc; - struct foo { a: int, b: int, } -type bar = Gc; +type bar = Box; fn want_foo(f: foo) {} fn have_bar(b: bar) { - want_foo(b); //~ ERROR (expected struct foo, found Gc-ptr) + want_foo(b); //~ ERROR (expected struct foo, found box) } fn main() {} diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs index bd844cc5860..73224c7b45c 100644 --- a/src/test/compile-fail/trait-impl-method-mismatch.rs +++ b/src/test/compile-fail/trait-impl-method-mismatch.rs @@ -9,15 +9,13 @@ // except according to those terms. -use std::gc::Gc; - trait Mumbo { - fn jumbo(&self, x: Gc) -> uint; + fn jumbo(&self, x: &uint) -> uint; } impl Mumbo for uint { // Cannot have a larger effect than the trait: - unsafe fn jumbo(&self, x: Gc) { *self + *x; } + unsafe fn jumbo(&self, x: &uint) { *self + *x; } //~^ ERROR expected normal fn, found unsafe fn } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index 7d6cdaef85b..4c2805bf4bd 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -9,12 +9,12 @@ // except according to those terms. -use std::gc::GC; +use std::rc::Rc; fn f(_i: T) { } fn main() { - let i = box box(GC) 100i; + let i = box Rc::new(100i); f(i); //~ ERROR `core::kinds::Send` is not implemented } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index 54b1fdea719..79f29c6b359 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -10,16 +10,15 @@ #![feature(unsafe_destructor)] -extern crate debug; use std::cell::Cell; -use std::gc::{Gc, GC}; -struct r { - i: Gc>, +#[deriving(Show)] +struct r<'a> { + i: &'a Cell, } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { unsafe { self.i.set(self.i.get() + 1); @@ -31,13 +30,13 @@ fn f(_i: Vec , _j: Vec ) { } fn main() { - let i1 = box(GC) Cell::new(0); - let i2 = box(GC) Cell::new(1); + let i1 = &Cell::new(0); + let i2 = &Cell::new(1); let r1 = vec!(box r { i: i1 }); let r2 = vec!(box r { i: i2 }); f(r1.clone(), r2.clone()); //~^ ERROR the trait `core::clone::Clone` is not implemented //~^^ ERROR the trait `core::clone::Clone` is not implemented - println!("{:?}", (r2, i1.get())); - println!("{:?}", (r1, i2.get())); + println!("{}", (r2, i1.get())); + println!("{}", (r1, i2.get())); } diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs index c3fea8e86d4..102cb636550 100644 --- a/src/test/compile-fail/unsendable-class.rs +++ b/src/test/compile-fail/unsendable-class.rs @@ -12,14 +12,14 @@ // Test that a class with an unsendable field can't be // sent -use std::gc::{Gc, GC}; +use std::rc::Rc; struct foo { i: int, - j: Gc, + j: Rc, } -fn foo(i:int, j: Gc) -> foo { +fn foo(i:int, j: Rc) -> foo { foo { i: i, j: j @@ -29,5 +29,5 @@ fn foo(i:int, j: Gc) -> foo { fn main() { let cat = "kitty".to_string(); let (tx, _) = channel(); //~ ERROR `core::kinds::Send` is not implemented - tx.send(foo(42, box(GC) (cat))); //~ ERROR `core::kinds::Send` is not implemented + tx.send(foo(42, Rc::new(cat))); //~ ERROR `core::kinds::Send` is not implemented } diff --git a/src/test/debuginfo/borrowed-managed-basic.rs b/src/test/debuginfo/borrowed-managed-basic.rs deleted file mode 100644 index a2b8c54c380..00000000000 --- a/src/test/debuginfo/borrowed-managed-basic.rs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - - -// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only -// its numerical value. - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish -// gdb-command:print *bool_ref -// gdb-check:$1 = true - -// gdb-command:print *int_ref -// gdb-check:$2 = -1 - -// gdb-command:print *char_ref -// gdb-check:$3 = 97 - -// gdb-command:print/d *i8_ref -// gdb-check:$4 = 68 - -// gdb-command:print *i16_ref -// gdb-check:$5 = -16 - -// gdb-command:print *i32_ref -// gdb-check:$6 = -32 - -// gdb-command:print *i64_ref -// gdb-check:$7 = -64 - -// gdb-command:print *uint_ref -// gdb-check:$8 = 1 - -// gdb-command:print/d *u8_ref -// gdb-check:$9 = 100 - -// gdb-command:print *u16_ref -// gdb-check:$10 = 16 - -// gdb-command:print *u32_ref -// gdb-check:$11 = 32 - -// gdb-command:print *u64_ref -// gdb-check:$12 = 64 - -// gdb-command:print *f32_ref -// gdb-check:$13 = 2.5 - -// gdb-command:print *f64_ref -// gdb-check:$14 = 3.5 - - -// === LLDB TESTS ================================================================================== - -// lldb-command:type format add -f decimal char -// lldb-command:type format add -f decimal 'unsigned char' -// lldb-command:run - -// lldb-command:print *bool_ref -// lldb-check:[...]$0 = true - -// lldb-command:print *int_ref -// lldb-check:[...]$1 = -1 - -// LLDB can't handle 32bit chars yet -// d ebugger:print *char_ref -// c heck:[...]$x = 97 - -// lldb-command:print *i8_ref -// lldb-check:[...]$2 = 68 - -// lldb-command:print *i16_ref -// lldb-check:[...]$3 = -16 - -// lldb-command:print *i32_ref -// lldb-check:[...]$4 = -32 - -// lldb-command:print *i64_ref -// lldb-check:[...]$5 = -64 - -// lldb-command:print *uint_ref -// lldb-check:[...]$6 = 1 - -// lldb-command:print *u8_ref -// lldb-check:[...]$7 = 100 - -// lldb-command:print *u16_ref -// lldb-check:[...]$8 = 16 - -// lldb-command:print *u32_ref -// lldb-check:[...]$9 = 32 - -// lldb-command:print *u64_ref -// lldb-check:[...]$10 = 64 - -// lldb-command:print *f32_ref -// lldb-check:[...]$11 = 2.5 - -// lldb-command:print *f64_ref -// lldb-check:[...]$12 = 3.5 - -#![allow(unused_variable)] - -use std::gc::{Gc, GC}; - -fn main() { - let bool_box: Gc = box(GC) true; - let bool_ref: &bool = &*bool_box; - - let int_box: Gc = box(GC) -1; - let int_ref: &int = &*int_box; - - let char_box: Gc = box(GC) 'a'; - let char_ref: &char = &*char_box; - - let i8_box: Gc = box(GC) 68; - let i8_ref: &i8 = &*i8_box; - - let i16_box: Gc = box(GC) -16; - let i16_ref: &i16 = &*i16_box; - - let i32_box: Gc = box(GC) -32; - let i32_ref: &i32 = &*i32_box; - - let i64_box: Gc = box(GC) -64; - let i64_ref: &i64 = &*i64_box; - - let uint_box: Gc = box(GC) 1; - let uint_ref: &uint = &*uint_box; - - let u8_box: Gc = box(GC) 100; - let u8_ref: &u8 = &*u8_box; - - let u16_box: Gc = box(GC) 16; - let u16_ref: &u16 = &*u16_box; - - let u32_box: Gc = box(GC) 32; - let u32_ref: &u32 = &*u32_box; - - let u64_box: Gc = box(GC) 64; - let u64_ref: &u64 = &*u64_box; - - let f32_box: Gc = box(GC) 2.5; - let f32_ref: &f32 = &*f32_box; - - let f64_box: Gc = box(GC) 3.5; - let f64_ref: &f64 = &*f64_box; - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/borrowed-struct.rs b/src/test/debuginfo/borrowed-struct.rs index 02131734fb1..8b9c790bbbf 100644 --- a/src/test/debuginfo/borrowed-struct.rs +++ b/src/test/debuginfo/borrowed-struct.rs @@ -29,15 +29,6 @@ // gdb-command:print *ref_to_unnamed // gdb-check:$4 = {x = 11, y = 24.5} -// gdb-command:print *managed_val_ref -// gdb-check:$5 = {x = 12, y = 25.5} - -// gdb-command:print *managed_val_interior_ref_1 -// gdb-check:$6 = 12 - -// gdb-command:print *managed_val_interior_ref_2 -// gdb-check:$7 = 25.5 - // gdb-command:print *unique_val_ref // gdb-check:$8 = {x = 13, y = 26.5} @@ -64,15 +55,6 @@ // lldb-command:print *ref_to_unnamed // lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 } -// lldb-command:print *managed_val_ref -// lldb-check:[...]$4 = SomeStruct { x: 12, y: 25.5 } - -// lldb-command:print *managed_val_interior_ref_1 -// lldb-check:[...]$5 = 12 - -// lldb-command:print *managed_val_interior_ref_2 -// lldb-check:[...]$6 = 25.5 - // lldb-command:print *unique_val_ref // lldb-check:[...]$7 = SomeStruct { x: 13, y: 26.5 } @@ -84,8 +66,6 @@ #![allow(unused_variable)] -use std::gc::GC; - struct SomeStruct { x: int, y: f64 @@ -98,11 +78,6 @@ fn main() { let stack_val_interior_ref_2: &f64 = &stack_val.y; let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 }; - let managed_val = box(GC) SomeStruct { x: 12, y: 25.5 }; - let managed_val_ref: &SomeStruct = &*managed_val; - let managed_val_interior_ref_1: &int = &managed_val.x; - let managed_val_interior_ref_2: &f64 = &managed_val.y; - let unique_val = box SomeStruct { x: 13, y: 26.5 }; let unique_val_ref: &SomeStruct = &*unique_val; let unique_val_interior_ref_1: &int = &unique_val.x; diff --git a/src/test/debuginfo/borrowed-tuple.rs b/src/test/debuginfo/borrowed-tuple.rs index 55530636571..2c78d14a86c 100644 --- a/src/test/debuginfo/borrowed-tuple.rs +++ b/src/test/debuginfo/borrowed-tuple.rs @@ -25,9 +25,6 @@ // gdb-command:print *ref_to_unnamed // gdb-check:$2 = {-15, -20} -// gdb-command:print *managed_val_ref -// gdb-check:$3 = {-16, -21} - // gdb-command:print *unique_val_ref // gdb-check:$4 = {-17, -22} @@ -42,25 +39,17 @@ // lldb-command:print *ref_to_unnamed // lldb-check:[...]$1 = (-15, -20) -// lldb-command:print *managed_val_ref -// lldb-check:[...]$2 = (-16, -21) - // lldb-command:print *unique_val_ref // lldb-check:[...]$3 = (-17, -22) #![allow(unused_variable)] -use std::gc::{Gc, GC}; - fn main() { let stack_val: (i16, f32) = (-14, -19f32); let stack_val_ref: &(i16, f32) = &stack_val; let ref_to_unnamed: &(i16, f32) = &(-15, -20f32); - let managed_val: Gc<(i16, f32)> = box(GC) (-16, -21f32); - let managed_val_ref: &(i16, f32) = &*managed_val; - let unique_val: Box<(i16, f32)> = box() (-17, -22f32); let unique_val_ref: &(i16, f32) = &*unique_val; diff --git a/src/test/debuginfo/box.rs b/src/test/debuginfo/box.rs index 1a07f614c14..c459b9be3d0 100644 --- a/src/test/debuginfo/box.rs +++ b/src/test/debuginfo/box.rs @@ -22,10 +22,6 @@ // gdb-check:$1 = 1 // gdb-command:print *b // gdb-check:$2 = {2, 3.5} -// gdb-command:print c->val -// gdb-check:$3 = 4 -// gdb-command:print d->val -// gdb-check:$4 = false // === LLDB TESTS ================================================================================== @@ -35,20 +31,12 @@ // lldb-check:[...]$0 = 1 // lldb-command:print *b // lldb-check:[...]$1 = (2, 3.5) -// lldb-command:print c->val -// lldb-check:[...]$2 = 4 -// lldb-command:print d->val -// lldb-check:[...]$3 = false #![allow(unused_variable)] -use std::gc::GC; - fn main() { let a = box 1i; let b = box() (2i, 3.5f64); - let c = box(GC) 4i; - let d = box(GC) false; zzz(); // #break } diff --git a/src/test/debuginfo/boxed-struct.rs b/src/test/debuginfo/boxed-struct.rs index d3a556e4009..a22b9fdea5c 100644 --- a/src/test/debuginfo/boxed-struct.rs +++ b/src/test/debuginfo/boxed-struct.rs @@ -21,15 +21,9 @@ // gdb-command:print *unique // gdb-check:$1 = {x = 99, y = 999, z = 9999, w = 99999} -// gdb-command:print managed->val -// gdb-check:$2 = {x = 88, y = 888, z = 8888, w = 88888} - // gdb-command:print *unique_dtor // gdb-check:$3 = {x = 77, y = 777, z = 7777, w = 77777} -// gdb-command:print managed_dtor->val -// gdb-check:$4 = {x = 33, y = 333, z = 3333, w = 33333} - // === LLDB TESTS ================================================================================== @@ -38,19 +32,11 @@ // lldb-command:print *unique // lldb-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 } -// lldb-command:print managed->val -// lldb-check:[...]$1 = StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 } - // lldb-command:print *unique_dtor // lldb-check:[...]$2 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 } -// lldb-command:print managed_dtor->val -// lldb-check:[...]$3 = StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 } - #![allow(unused_variable)] -use std::gc::GC; - struct StructWithSomePadding { x: i16, y: i32, @@ -72,11 +58,8 @@ impl Drop for StructWithDestructor { fn main() { let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }; - let managed = box(GC) StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 }; let unique_dtor = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }; - let managed_dtor = box(GC) StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 }; - zzz(); // #break } diff --git a/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs b/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs index af1b38adf80..11df00ee4fe 100644 --- a/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs +++ b/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs @@ -33,11 +33,6 @@ // gdb-check:$3 = {4444.5, 5555, 6666, 7777.5} // gdb-command:continue -// gdb-command:finish -// gdb-command:print self->val -// gdb-check:$4 = 8888 -// gdb-command:continue - // === LLDB TESTS ================================================================================== @@ -55,12 +50,6 @@ // lldb-check:[...]$2 = (4444.5, 5555, 6666, 7777.5) // lldb-command:continue -// lldb-command:print self->val -// lldb-check:[...]$3 = 8888 -// lldb-command:continue - -use std::gc::{Gc, GC}; - trait Trait { fn method(self) -> Self; } @@ -91,18 +80,10 @@ impl Trait for (f64, int, int, f64) { } } -impl Trait for Gc { - fn method(self) -> Gc { - zzz(); // #break - self - } -} - fn main() { let _ = (1111 as int).method(); let _ = Struct { x: 2222, y: 3333 }.method(); let _ = (4444.5, 5555, 6666, 7777.5).method(); - let _ = (box(GC) 8888).method(); } fn zzz() { () } diff --git a/src/test/debuginfo/managed-enum.rs b/src/test/debuginfo/managed-enum.rs deleted file mode 100644 index e5da4d2cdb1..00000000000 --- a/src/test/debuginfo/managed-enum.rs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish - -// gdb-command:print the_a->val -// gdb-check:$1 = {{TheA, x = 0, y = 8970181431921507452}, {TheA, 0, 2088533116, 2088533116}} - -// gdb-command:print the_b->val -// gdb-check:$2 = {{TheB, x = 0, y = 1229782938247303441}, {TheB, 0, 286331153, 286331153}} - -// gdb-command:print univariant->val -// gdb-check:$3 = {{-9747455}} - - -// === LLDB TESTS ================================================================================== - -// lldb-command:run - -// lldb-command:print the_a->val -// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } - -// lldb-command:print the_b->val -// lldb-check:[...]$1 = TheB(0, 286331153, 286331153) - -// lldb-command:print univariant->val -// lldb-check:[...]$2 = TheOnlyCase(-9747455) - -#![allow(unused_variable)] -#![feature(struct_variant)] - -use std::gc::GC; - -// The first element is to ensure proper alignment, irrespective of the machines word size. Since -// the size of the discriminant value is machine dependent, this has be taken into account when -// datatype layout should be predictable as in this case. -enum ABC { - TheA { x: i64, y: i64 }, - TheB (i64, i32, i32), -} - -// This is a special case since it does not have the implicit discriminant field. -enum Univariant { - TheOnlyCase(i64) -} - -fn main() { - - // In order to avoid endianess trouble all of the following test values consist of a single - // repeated byte. This way each interpretation of the union should look the same, no matter if - // this is a big or little endian machine. - - // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 - // 0b01111100011111000111110001111100 = 2088533116 - // 0b0111110001111100 = 31868 - // 0b01111100 = 124 - let the_a = box(GC) TheA { x: 0, y: 8970181431921507452 }; - - // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 - // 0b00010001000100010001000100010001 = 286331153 - // 0b0001000100010001 = 4369 - // 0b00010001 = 17 - let the_b = box(GC) TheB (0, 286331153, 286331153); - - let univariant = box(GC) TheOnlyCase(-9747455); - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/managed-pointer-within-unique-vec.rs b/src/test/debuginfo/managed-pointer-within-unique-vec.rs deleted file mode 100644 index 69f3938ecee..00000000000 --- a/src/test/debuginfo/managed-pointer-within-unique-vec.rs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish - -// gdb-command:print unique.ptr[0]->val -// gdb-check:$1 = 10 - -// gdb-command:print unique.ptr[1]->val -// gdb-check:$2 = 11 - -// gdb-command:print unique.ptr[2]->val -// gdb-check:$3 = 12 - -// gdb-command:print unique.ptr[3]->val -// gdb-check:$4 = 13 - - -// === LLDB TESTS ================================================================================== - -// lldb-command:run - -// lldb-command:print unique.ptr[0]->val -// lldb-check:[...]$0 = 10 - -// lldb-command:print unique.ptr[1]->val -// lldb-check:[...]$1 = 11 - -// lldb-command:print unique.ptr[2]->val -// lldb-check:[...]$2 = 12 - -// lldb-command:print unique.ptr[3]->val -// lldb-check:[...]$3 = 13 - - -#![allow(unused_variable)] - -use std::gc::{Gc, GC}; - -fn main() { - - let unique: Vec> = vec!(box(GC) 10, box(GC) 11, box(GC) 12, box(GC) 13); - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/managed-pointer-within-unique.rs b/src/test/debuginfo/managed-pointer-within-unique.rs deleted file mode 100644 index 2690efb8f85..00000000000 --- a/src/test/debuginfo/managed-pointer-within-unique.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:set print pretty off -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish - -// gdb-command:print *ordinary_unique -// gdb-check:$1 = {-1, -2} - -// gdb-command:print managed_within_unique->x -// gdb-check:$2 = -3 - -// gdb-command:print managed_within_unique->y->val -// gdb-check:$3 = -4 - -// === LLDB TESTS ================================================================================== - -// lldb-command:run - -// lldb-command:print *ordinary_unique -// lldb-check:[...]$0 = (-1, -2) - -// lldb-command:print managed_within_unique->x -// lldb-check:[...]$1 = -3 - -// lldb-command:print managed_within_unique->y->val -// lldb-check:[...]$2 = -4 - -#![allow(unused_variable)] - -use std::gc::{GC, Gc}; - -struct ContainsManaged { - x: int, - y: Gc, -} - -fn main() { - let ordinary_unique = box() (-1i, -2i); - - let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4i }; - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/recursive-struct.rs b/src/test/debuginfo/recursive-struct.rs index 76722b743d7..412bdfaaf15 100644 --- a/src/test/debuginfo/recursive-struct.rs +++ b/src/test/debuginfo/recursive-struct.rs @@ -29,11 +29,6 @@ // gdb-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value // gdb-check:$4 = 3 -// gdb-command:print box_unique->val.value -// gdb-check:$5 = 4 -// gdb-command:print box_unique->val.next.RUST$ENCODED$ENUM$0$Empty.val->value -// gdb-check:$6 = 5 - // gdb-command:print vec_unique[0].value // gdb-check:$7 = 6.5 // gdb-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value @@ -44,32 +39,6 @@ // gdb-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value // gdb-check:$10 = 9.5 -// MANAGED -// gdb-command:print stack_managed.value -// gdb-check:$11 = 10 -// gdb-command:print stack_managed.next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$12 = 11 - -// gdb-command:print unique_managed->value -// gdb-check:$13 = 12 -// gdb-command:print unique_managed->next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$14 = 13 - -// gdb-command:print box_managed.val->value -// gdb-check:$15 = 14 -// gdb-command:print box_managed->val->next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$16 = 15 - -// gdb-command:print vec_managed[0].value -// gdb-check:$17 = 16.5 -// gdb-command:print vec_managed[0].next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$18 = 17.5 - -// gdb-command:print borrowed_managed->value -// gdb-check:$19 = 18.5 -// gdb-command:print borrowed_managed->next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$20 = 19.5 - // LONG CYCLE // gdb-command:print long_cycle1.value // gdb-check:$21 = 20 @@ -106,8 +75,6 @@ #![allow(unused_variable)] #![feature(struct_variant)] -use std::gc::{Gc, GC}; - enum Opt { Empty, Val { val: T } @@ -118,11 +85,6 @@ struct UniqueNode { value: T } -struct ManagedNode { - next: Opt>>, - value: T -} - struct LongCycle1 { next: Box>, value: T, @@ -184,16 +146,6 @@ fn main() { value: 2, }; - let box_unique: Gc> = box(GC) UniqueNode { - next: Val { - val: box UniqueNode { - next: Empty, - value: 5, - } - }, - value: 4, - }; - let vec_unique: [UniqueNode, ..1] = [UniqueNode { next: Val { val: box UniqueNode { @@ -214,56 +166,6 @@ fn main() { value: 8.5, }; - let stack_managed: ManagedNode = ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 11, - } - }, - value: 10, - }; - - let unique_managed: Box> = box ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 13, - } - }, - value: 12, - }; - - let box_managed: Gc> = box(GC) ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 15, - } - }, - value: 14, - }; - - let vec_managed: [ManagedNode, ..1] = [ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 17.5, - } - }, - value: 16.5, - }]; - - let borrowed_managed: &ManagedNode = &ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 19.5, - } - }, - value: 18.5, - }; - // LONG CYCLE let long_cycle1: LongCycle1 = LongCycle1 { next: box LongCycle2 { diff --git a/src/test/debuginfo/var-captured-in-nested-closure.rs b/src/test/debuginfo/var-captured-in-nested-closure.rs index a08cc6bdb6e..89415df3588 100644 --- a/src/test/debuginfo/var-captured-in-nested-closure.rs +++ b/src/test/debuginfo/var-captured-in-nested-closure.rs @@ -28,8 +28,6 @@ // gdb-check:$4 = {a = -3, b = 4.5, c = 5} // gdb-command:print *owned // gdb-check:$5 = 6 -// gdb-command:print managed->val -// gdb-check:$6 = 7 // gdb-command:print closure_local // gdb-check:$7 = 8 // gdb-command:continue @@ -45,8 +43,6 @@ // gdb-check:$11 = {a = -3, b = 4.5, c = 5} // gdb-command:print *owned // gdb-check:$12 = 6 -// gdb-command:print managed->val -// gdb-check:$13 = 7 // gdb-command:print closure_local // gdb-check:$14 = 8 // gdb-command:continue @@ -66,8 +62,6 @@ // lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned // lldb-check:[...]$4 = 6 -// lldb-command:print managed->val -// lldb-check:[...]$5 = 7 // lldb-command:print closure_local // lldb-check:[...]$6 = 8 // lldb-command:continue @@ -82,16 +76,12 @@ // lldb-check:[...]$10 = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned // lldb-check:[...]$11 = 6 -// lldb-command:print managed->val -// lldb-check:[...]$12 = 7 // lldb-command:print closure_local // lldb-check:[...]$13 = 8 // lldb-command:continue #![allow(unused_variable)] -use std::gc::GC; - struct Struct { a: int, b: f64, @@ -110,14 +100,13 @@ fn main() { let struct_ref = &a_struct; let owned = box 6; - let managed = box(GC) 7; let closure = || { let closure_local = 8; let nested_closure = || { zzz(); // #break - variable = constant + a_struct.a + struct_ref.a + *owned + *managed + closure_local; + variable = constant + a_struct.a + struct_ref.a + *owned + closure_local; }; zzz(); // #break diff --git a/src/test/debuginfo/var-captured-in-stack-closure.rs b/src/test/debuginfo/var-captured-in-stack-closure.rs index c37f0ddbe99..8ea407fc544 100644 --- a/src/test/debuginfo/var-captured-in-stack-closure.rs +++ b/src/test/debuginfo/var-captured-in-stack-closure.rs @@ -28,8 +28,6 @@ // gdb-check:$4 = {a = -3, b = 4.5, c = 5} // gdb-command:print *owned // gdb-check:$5 = 6 -// gdb-command:print managed->val -// gdb-check:$6 = 7 // === LLDB TESTS ================================================================================== @@ -46,13 +44,9 @@ // lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned // lldb-check:[...]$4 = 6 -// lldb-command:print managed->val -// lldb-check:[...]$5 = 7 #![allow(unused_variable)] -use std::gc::GC; - struct Struct { a: int, b: f64, @@ -71,11 +65,10 @@ fn main() { let struct_ref = &a_struct; let owned = box 6; - let managed = box(GC) 7; let closure = || { zzz(); // #break - variable = constant + a_struct.a + struct_ref.a + *owned + *managed; + variable = constant + a_struct.a + struct_ref.a + *owned; }; closure(); diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 3f6d5b8c18a..01fc70c1d2c 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -14,34 +14,33 @@ use std::cell::Cell; -use std::gc::GC; -fn test1() { let val = box(GC) 0i; { } *val; } +fn test1() { let val = &0i; { } *val; } -fn test2() -> int { let val = box(GC) 0i; { } *val } +fn test2() -> int { let val = &0i; { } *val } struct S { eax: int } fn test3() { - let regs = box(GC) Cell::new(S {eax: 0}); + let regs = &Cell::new(S {eax: 0}); match true { true => { } _ => { } } regs.set(S {eax: 1}); } -fn test4() -> bool { let regs = box(GC) true; if true { } *regs || false } +fn test4() -> bool { let regs = &true; if true { } *regs || false } fn test5() -> (int, int) { { } (0, 1) } fn test6() -> bool { { } (true || false) && true } fn test7() -> uint { - let regs = box(GC) 0i; + let regs = &0i; match true { true => { } _ => { } } (*regs < 2) as uint } fn test8() -> int { - let val = box(GC) 0i; + let val = &0i; match true { true => { } _ => { } @@ -54,12 +53,12 @@ fn test8() -> int { } fn test9() { - let regs = box(GC) Cell::new(0i); + let regs = &Cell::new(0i); match true { true => { } _ => { } } regs.set(regs.get() + 1); } fn test10() -> int { - let regs = box(GC) vec!(0i); + let regs = vec!(0i); match true { true => { } _ => { } } *(*regs).get(0) } diff --git a/src/test/run-fail/args-fail.rs b/src/test/run-fail/args-fail.rs index d8ba7e1b788..5e1b7bb69bb 100644 --- a/src/test/run-fail/args-fail.rs +++ b/src/test/run-fail/args-fail.rs @@ -11,8 +11,6 @@ // error-pattern:meep -use std::gc::{Gc, GC}; +fn f(_a: int, _b: int, _c: Box) { fail!("moop"); } -fn f(_a: int, _b: int, _c: Gc) { fail!("moop"); } - -fn main() { f(1, fail!("meep"), box(GC) 42); } +fn main() { f(1, fail!("meep"), box 42); } diff --git a/src/test/run-fail/issue-2272.rs b/src/test/run-fail/issue-2272.rs deleted file mode 100644 index 87de4d3d3f2..00000000000 --- a/src/test/run-fail/issue-2272.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern:explicit failure -// Issue #2272 - unwind this without leaking the unique pointer - -use std::gc::{Gc, GC}; - -struct X { y: Y, a: Box } - -struct Y { z: Gc } - -fn main() { - let _x = X { - y: Y { - z: box(GC) 0 - }, - a: box 0 - }; - fail!(); -} diff --git a/src/test/run-fail/unwind-assert.rs b/src/test/run-fail/unwind-assert.rs deleted file mode 100644 index 4947093d10c..00000000000 --- a/src/test/run-fail/unwind-assert.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn main() { - let _a = box(GC) 0i; - assert!(false); -} diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs deleted file mode 100644 index 7ed58be6072..00000000000 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern:fail - -extern crate debug; - -use std::gc::{GC, Gc}; - -fn failfn() { - fail!(); -} - -fn main() { - let y = box 0i; - let x: Gc = box(GC) (proc() { - println!("{:?}", y.clone()); - }); - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs deleted file mode 100644 index ede83311732..00000000000 --- a/src/test/run-fail/unwind-box-res.rs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::mem; -use std::gc::GC; - -fn failfn() { - fail!(); -} - -struct r { - v: *const int, -} - -impl Drop for r { - fn drop(&mut self) { - unsafe { - let _v2: Box = mem::transmute(self.v); - } - } -} - -fn r(v: *const int) -> r { - r { - v: v - } -} - -fn main() { - unsafe { - let i1 = box 0i; - let i1p = mem::transmute_copy(&i1); - mem::forget(i1); - let x = box(GC) r(i1p); - failfn(); - println!("{:?}", x); - } -} diff --git a/src/test/run-fail/unwind-box-str.rs b/src/test/run-fail/unwind-box-str.rs deleted file mode 100644 index 07a8f5d4cfa..00000000000 --- a/src/test/run-fail/unwind-box-str.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) "hi".to_string(); - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-unique-unique.rs b/src/test/run-fail/unwind-box-unique-unique.rs deleted file mode 100644 index 9aa916a062e..00000000000 --- a/src/test/run-fail/unwind-box-unique-unique.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) box box 0i; - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-unique.rs b/src/test/run-fail/unwind-box-unique.rs deleted file mode 100644 index 7135742db34..00000000000 --- a/src/test/run-fail/unwind-box-unique.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) box 0i; - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-vec.rs b/src/test/run-fail/unwind-box-vec.rs deleted file mode 100644 index e7d1476c2b6..00000000000 --- a/src/test/run-fail/unwind-box-vec.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) vec!(0i, 1, 2, 3, 4, 5); - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box.rs b/src/test/run-fail/unwind-box.rs deleted file mode 100644 index 7d93ae56156..00000000000 --- a/src/test/run-fail/unwind-box.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - box(GC) 0i; - failfn(); -} diff --git a/src/test/run-fail/unwind-fail.rs b/src/test/run-fail/unwind-fail.rs deleted file mode 100644 index 1e19522871a..00000000000 --- a/src/test/run-fail/unwind-fail.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn main() { - box(GC) 0i; - fail!(); -} diff --git a/src/test/run-fail/unwind-initializer-indirect.rs b/src/test/run-fail/unwind-initializer-indirect.rs deleted file mode 100644 index 13ad5d2fae3..00000000000 --- a/src/test/run-fail/unwind-initializer-indirect.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::Gc; - -fn f() -> Gc { fail!(); } - -fn main() { - let _a: Gc = f(); -} diff --git a/src/test/run-fail/unwind-initializer.rs b/src/test/run-fail/unwind-initializer.rs deleted file mode 100644 index 7294b19ac9a..00000000000 --- a/src/test/run-fail/unwind-initializer.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::Gc; - -fn main() { - let _a: Gc = { - fail!(); - }; -} diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs deleted file mode 100644 index 411b9a56a2f..00000000000 --- a/src/test/run-fail/unwind-iter.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - -#![allow(unreachable_code)] -#![allow(unused_variable)] - -use std::gc::GC; - -fn x(it: |int|) { - fail!(); - it(0); -} - -fn main() { - let a = box(GC) 0i; - x(|_i| { } ); -} diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs deleted file mode 100644 index 1a2492e0ac8..00000000000 --- a/src/test/run-fail/unwind-iter2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::{GC}; - -fn x(it: |int|) { - let _a = box(GC) 0i; - it(1); -} - -fn main() { - x(|_x| fail!() ); -} diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs deleted file mode 100644 index e96bc14905e..00000000000 --- a/src/test/run-fail/unwind-lambda.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::{Gc, GC}; - -fn main() { - let cheese = "roquefort".to_string(); - let carrots = box(GC) "crunchy".to_string(); - - let result: |Gc, |String||: 'static = (|tasties, macerate| { - macerate((*tasties).clone()); - }); - result(carrots, |food| { - let mush = format!("{}{}", food, cheese); - let cheese = cheese.clone(); - let f: || = || { - let _chew = format!("{}{}", mush, cheese); - fail!("so yummy") - }; - f(); - }); -} diff --git a/src/test/run-fail/unwind-match.rs b/src/test/run-fail/unwind-match.rs deleted file mode 100644 index a6564a68e19..00000000000 --- a/src/test/run-fail/unwind-match.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #945 -// error-pattern:non-exhaustive match failure - - -use std::gc::GC; - -fn test_box() { - box(GC) 0i; -} -fn test_str() { - let res = match false { true => { "happy".to_string() }, - _ => fail!("non-exhaustive match failure") }; - assert_eq!(res, "happy".to_string()); -} -fn main() { - test_box(); - test_str(); -} diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs deleted file mode 100644 index 23ec6cd0300..00000000000 --- a/src/test/run-fail/unwind-misc-1.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_NEWRT=1 -// error-pattern:fail - - -use std::vec; -use std::collections; -use std::gc::GC; - -fn main() { - let _count = box(GC) 0u; - let mut map = collections::HashMap::new(); - let mut arr = Vec::new(); - for _i in range(0u, 10u) { - arr.push(box(GC) "key stuff".to_string()); - map.insert(arr.clone(), - arr.clone().append([box(GC) "value stuff".to_string()])); - if arr.len() == 5 { - fail!(); - } - } -} diff --git a/src/test/run-fail/unwind-move.rs b/src/test/run-fail/unwind-move.rs deleted file mode 100644 index 692bf713b40..00000000000 --- a/src/test/run-fail/unwind-move.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::{Gc, GC}; - -fn f(_a: Gc) { - fail!(); -} - -fn main() { - let a = box(GC) 0; - f(a); -} diff --git a/src/test/run-fail/unwind-nested.rs b/src/test/run-fail/unwind-nested.rs deleted file mode 100644 index 84b727ea20f..00000000000 --- a/src/test/run-fail/unwind-nested.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn main() { - let _a = box(GC) 0i; - { - let _b = box(GC) 0i; - { - fail!(); - } - } -} diff --git a/src/test/run-fail/unwind-partial-box.rs b/src/test/run-fail/unwind-partial-box.rs deleted file mode 100644 index 366531b9127..00000000000 --- a/src/test/run-fail/unwind-partial-box.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() -> Vec { fail!(); } - -// Voodoo. In unwind-alt we had to do this to trigger the bug. Might -// have been to do with memory allocation patterns. -fn prime() { - box(GC) 0i; -} - -fn partial() { - let _x = box(GC) f(); -} - -fn main() { - prime(); - partial(); -} diff --git a/src/test/run-fail/unwind-partial-unique.rs b/src/test/run-fail/unwind-partial-unique.rs deleted file mode 100644 index 725b57af7df..00000000000 --- a/src/test/run-fail/unwind-partial-unique.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() -> Vec { fail!(); } - -// Voodoo. In unwind-alt we had to do this to trigger the bug. Might -// have been to do with memory allocation patterns. -fn prime() { - box(GC) 0i; -} - -fn partial() { - let _x = box f(); -} - -fn main() { - prime(); - partial(); -} diff --git a/src/test/run-fail/unwind-partial-vec.rs b/src/test/run-fail/unwind-partial-vec.rs deleted file mode 100644 index 627fb3d028e..00000000000 --- a/src/test/run-fail/unwind-partial-vec.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() -> Vec { fail!(); } - -// Voodoo. In unwind-alt we had to do this to trigger the bug. Might -// have been to do with memory allocation patterns. -fn prime() { - box(GC) 0i; -} - -fn partial() { - let _x = vec!(vec!(0i), f(), vec!(0i)); -} - -fn main() { - prime(); - partial(); -} diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs deleted file mode 100644 index 66fd044d64e..00000000000 --- a/src/test/run-fail/unwind-resource-fail.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern:squirrel - -use std::gc::GC; - -struct r { - i: int, -} - -impl Drop for r { - fn drop(&mut self) { fail!("squirrel") } -} - -fn r(i: int) -> r { r { i: i } } - -fn main() { - box(GC) 0i; - let _r = r(0); -} diff --git a/src/test/run-fail/unwind-resource-fail2.rs b/src/test/run-fail/unwind-resource-fail2.rs deleted file mode 100644 index add7fe3f0f3..00000000000 --- a/src/test/run-fail/unwind-resource-fail2.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test leaks -// error-pattern:wombat - -use std::gc::GC; - -struct r { - i: int, -} - -impl Drop for r { - fn drop(&mut self) { fail!("wombat") } -} - -fn r(i: int) -> r { r { i: i } } - -fn main() { - box(GC) 0; - let r = r(0); - fail!(); -} diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs deleted file mode 100644 index 9ec7c4a1eb3..00000000000 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unsafe_destructor)] - -// error-pattern:quux - -use std::gc::{Gc, GC}; - -struct faily_box { - i: Gc -} -// What happens to the box pointer owned by this class? - -fn faily_box(i: Gc) -> faily_box { faily_box { i: i } } - -#[unsafe_destructor] -impl Drop for faily_box { - fn drop(&mut self) { - fail!("quux"); - } -} - -fn main() { - faily_box(box(GC) 10); -} diff --git a/src/test/run-fail/unwind-stacked.rs b/src/test/run-fail/unwind-stacked.rs deleted file mode 100644 index 1e1caac0004..00000000000 --- a/src/test/run-fail/unwind-stacked.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() { - let _a = box(GC) 0i; - fail!(); -} - -fn g() { - let _b = box(GC) 0i; - f(); -} - -fn main() { - let _a = box(GC) 0i; - g(); -} diff --git a/src/test/run-fail/unwind-tup.rs b/src/test/run-fail/unwind-tup.rs deleted file mode 100644 index 877e2beb703..00000000000 --- a/src/test/run-fail/unwind-tup.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::Gc; - -// error-pattern:fail - -fn fold_local() -> Gc> { - fail!(); -} - -fn main() { - let _lss = (fold_local(), 0i); -} diff --git a/src/test/run-fail/unwind-tup2.rs b/src/test/run-fail/unwind-tup2.rs deleted file mode 100644 index 01536233ffe..00000000000 --- a/src/test/run-fail/unwind-tup2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// error-pattern:fail - -fn fold_local() -> Gc> { - box(GC) vec!(0,0,0,0,0,0) -} - -fn fold_remote() -> Gc> { - fail!(); -} - -fn main() { - let _lss = (fold_local(), fold_remote()); -} diff --git a/src/test/run-fail/unwind-uninitialized.rs b/src/test/run-fail/unwind-uninitialized.rs deleted file mode 100644 index 54321e98e73..00000000000 --- a/src/test/run-fail/unwind-uninitialized.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() { - fail!(); -} - -fn main() { - f(); - let _a = box(GC) 0i; -} diff --git a/src/test/run-pass/assert-eq-macro-success.rs b/src/test/run-pass/assert-eq-macro-success.rs index 7cc4fab999c..49a374f343c 100644 --- a/src/test/run-pass/assert-eq-macro-success.rs +++ b/src/test/run-pass/assert-eq-macro-success.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - #[deriving(PartialEq, Show)] struct Point { x : int } @@ -19,5 +17,4 @@ pub fn main() { assert_eq!("abc".to_string(),"abc".to_string()); assert_eq!(box Point{x:34},box Point{x:34}); assert_eq!(&Point{x:34},&Point{x:34}); - assert_eq!(box(GC) Point{x:34},box(GC) Point{x:34}); } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index 2bad924192f..cc4dd13cf61 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::{GC, Gc}; - trait double { fn double(self) -> uint; } @@ -19,11 +17,11 @@ impl double for uint { fn double(self) -> uint { self } } -impl double for Gc { +impl double for Box { fn double(self) -> uint { *self * 2u } } pub fn main() { - let x = box(GC) 3u; + let x = box 3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs index ac19c373bb2..7f44bcdb50c 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -9,15 +9,13 @@ // except according to those terms. -use std::gc::{Gc, GC}; - trait Foo { fn foo(&self) -> String; } -impl Foo for Gc { +impl Foo for Box { fn foo(&self) -> String { - format!("box(GC) {}", (**self).foo()) + format!("box {}", (**self).foo()) } } @@ -28,6 +26,6 @@ impl Foo for uint { } pub fn main() { - let x = box(GC) 3u; - assert_eq!(x.foo(), "box(GC) 3".to_string()); + let x = box 3u; + assert_eq!(x.foo(), "box 3".to_string()); } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 2551dafe345..3997c5d3d29 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -10,9 +10,6 @@ // Binop corner cases - -use std::gc::GC; - fn test_nil() { assert_eq!((), ()); assert!((!(() != ()))); @@ -45,10 +42,6 @@ fn test_bool() { assert_eq!(true ^ true, false); } -fn test_box() { - assert_eq!(box(GC) 10i, box(GC) 10i); -} - fn test_ptr() { unsafe { let p1: *const u8 = ::std::mem::transmute(0u); @@ -98,7 +91,6 @@ fn test_class() { pub fn main() { test_nil(); test_bool(); - test_box(); test_ptr(); test_class(); } diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index 7222d655a40..8c4995e7100 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -9,13 +9,11 @@ // except according to those terms. -use std::gc::{Gc, GC}; - fn borrow(x: &int, f: |x: &int|) { f(x) } -fn test1(x: Gc>) { +fn test1(x: &Box) { borrow(&*(*x).clone(), |p| { let x_a = &**x as *const int; assert!((x_a as uint) != (p as *const int as uint)); @@ -24,5 +22,5 @@ fn test1(x: Gc>) { } pub fn main() { - test1(box(GC) box 22); + test1(&box 22); } diff --git a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs b/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs deleted file mode 100644 index 525a93a4c83..00000000000 --- a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_POISON_ON_FREE=1 - -// Test that we root `x` even though it is found in immutable memory, -// because it is moved. - - -use std::gc::{Gc, GC}; - -fn free(x: Gc) {} - -struct Foo { - f: Gc -} - -struct Bar { - g: int -} - -fn lend(x: Gc) -> int { - let y = &x.f.g; - free(x); // specifically here, if x is not rooted, it will be freed - *y -} - -pub fn main() { - assert_eq!(lend(box(GC) Foo {f: box(GC) Bar {g: 22}}), 22); -} diff --git a/src/test/run-pass/borrowck-root-while-cond-2.rs b/src/test/run-pass/borrowck-root-while-cond-2.rs deleted file mode 100644 index 344867568bb..00000000000 --- a/src/test/run-pass/borrowck-root-while-cond-2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -struct F { f: Gc } -struct G { g: Vec } - -pub fn main() { - let rec = box(GC) F {f: box(GC) G {g: vec!(1, 2, 3)}}; - while rec.f.g.len() == 23 {} -} diff --git a/src/test/run-pass/borrowck-root-while-cond.rs b/src/test/run-pass/borrowck-root-while-cond.rs deleted file mode 100644 index 163ccf5c029..00000000000 --- a/src/test/run-pass/borrowck-root-while-cond.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn borrow<'r,T>(x: &'r T) -> &'r T {x} - -struct Rec { f: Gc } - -pub fn main() { - let rec = box(GC) Rec {f: box(GC) 22}; - while *borrow(&*rec.f) == 23 {} -} diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index 8192566da19..129fa8bf7d9 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -10,7 +10,6 @@ use std::cell::Cell; -use std::gc::GC; enum newtype { newvar(int) @@ -21,8 +20,8 @@ pub fn main() { // Test that borrowck treats enums with a single variant // specially. - let x = box(GC) Cell::new(5); - let y = box(GC) Cell::new(newvar(3)); + let x = &Cell::new(5); + let y = &Cell::new(newvar(3)); let z = match y.get() { newvar(b) => { x.set(x.get() + 1); diff --git a/src/test/run-pass/box-compare.rs b/src/test/run-pass/box-compare.rs deleted file mode 100644 index 9e8e416d7b0..00000000000 --- a/src/test/run-pass/box-compare.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -pub fn main() { - assert!((box(GC) 1i < box(GC) 3i)); - assert!((box(GC) box(GC) "hello ".to_string() > - box(GC) box(GC) "hello".to_string())); - assert!((box(GC) box(GC) box(GC) "hello".to_string() != - box(GC) box(GC) box(GC) "there".to_string())); -} diff --git a/src/test/run-pass/box-in-tup.rs b/src/test/run-pass/box-in-tup.rs deleted file mode 100644 index 8d7bb55028f..00000000000 --- a/src/test/run-pass/box-in-tup.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -pub fn main() { - let i: (Gc, int) = (box(GC) 10, 10); - let (_a, _) = i; -} diff --git a/src/test/run-pass/box-inside-if.rs b/src/test/run-pass/box-inside-if.rs deleted file mode 100644 index 47c7e7f16f4..00000000000 --- a/src/test/run-pass/box-inside-if.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -fn some_box(x: int) -> Gc { return box(GC) x; } - -fn is_odd(_n: int) -> bool { return true; } - -fn length_is_even(_vs: Gc) -> bool { return true; } - -fn foo(_acc: int, n: int) { - if is_odd(n) && length_is_even(some_box(1)) { println!("bloop"); } -} - -pub fn main() { foo(67, 5); } diff --git a/src/test/run-pass/box-inside-if2.rs b/src/test/run-pass/box-inside-if2.rs deleted file mode 100644 index e62050c8ea9..00000000000 --- a/src/test/run-pass/box-inside-if2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn some_box(x: int) -> Gc { return box(GC) x; } - -fn is_odd(_n: int) -> bool { return true; } - -fn length_is_even(_vs: Gc) -> bool { return true; } - -fn foo(_acc: int, n: int) { - if is_odd(n) || length_is_even(some_box(1)) { println!("bloop"); } -} - -pub fn main() { foo(67, 5); } diff --git a/src/test/run-pass/box-pattern.rs b/src/test/run-pass/box-pattern.rs deleted file mode 100644 index 21d1d235901..00000000000 --- a/src/test/run-pass/box-pattern.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let box x = box 3i; - match box 3i { - box y => { - assert!(x == y); - println!("{} {}", x, y); - } - } -} - diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs deleted file mode 100644 index bc8afff0cd6..00000000000 --- a/src/test/run-pass/box-unbox.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Box {c: Gc} - -fn unbox(b: Box) -> T { return (*b.c).clone(); } - -pub fn main() { - let foo: int = 17; - let bfoo: Box = Box {c: box(GC) foo}; - println!("see what's in our box"); - assert_eq!(unbox::(bfoo), foo); -} diff --git a/src/test/run-pass/box.rs b/src/test/run-pass/box.rs deleted file mode 100644 index 844b9392ec8..00000000000 --- a/src/test/run-pass/box.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -pub fn main() { let x: Gc = box(GC) 10; assert!((*x == 10)); } diff --git a/src/test/run-pass/boxed-class-type-substitution.rs b/src/test/run-pass/boxed-class-type-substitution.rs deleted file mode 100644 index 41ffdd7b4b9..00000000000 --- a/src/test/run-pass/boxed-class-type-substitution.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test that rustc doesn't recurse infinitely substituting -// the boxed type parameter - - -use std::gc::Gc; - -struct Tree { - parent: Option -} - -fn empty() -> Tree { fail!() } - -struct Box { - tree: Tree> -} - -fn Box() -> Box { - Box { - tree: empty() - } -} - -struct LayoutData { - a_box: Option> -} - -pub fn main() { } diff --git a/src/test/run-pass/cci_borrow.rs b/src/test/run-pass/cci_borrow.rs index e319866d5ce..262c19174b1 100644 --- a/src/test/run-pass/cci_borrow.rs +++ b/src/test/run-pass/cci_borrow.rs @@ -13,10 +13,9 @@ extern crate cci_borrow_lib; use cci_borrow_lib::foo; -use std::gc::GC; pub fn main() { - let p = box(GC) 22u; + let p = box 22u; let r = foo(&*p); println!("r={}", r); assert_eq!(r, 22u); diff --git a/src/test/run-pass/classes-self-referential.rs b/src/test/run-pass/classes-self-referential.rs index 099431acd24..a54a821a7b9 100644 --- a/src/test/run-pass/classes-self-referential.rs +++ b/src/test/run-pass/classes-self-referential.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - struct kitten { cat: Option, } @@ -21,6 +19,6 @@ fn kitten(cat: Option) -> kitten { } } -type cat = Gc; +type cat = Box; pub fn main() {} diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs deleted file mode 100644 index 3eec506c9e3..00000000000 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::task; -use std::gc::{GC, Gc}; - -fn adder(x: Gc, y: Gc) -> int { return *x + *y; } -fn failer() -> Gc { fail!(); } -pub fn main() { - assert!(task::try(proc() { - adder(box(GC) 2, failer()); () - }).is_err()); -} diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 481a922a463..0088a36eda9 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -17,12 +17,10 @@ extern crate crate_method_reexport_grrrrrrr2; -use std::gc::GC; - pub fn main() { use crate_method_reexport_grrrrrrr2::rust::add; use crate_method_reexport_grrrrrrr2::rust::cx; - let x = box(GC) (); + let x = box() (); x.cx(); let y = (); y.add("hi".to_string()); diff --git a/src/test/run-pass/cycle-collection.rs b/src/test/run-pass/cycle-collection.rs deleted file mode 100644 index edcbd21476b..00000000000 --- a/src/test/run-pass/cycle-collection.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum taggy { - cons(Gc>), - nil, -} - -fn f() { - let a_box = box(GC) RefCell::new(nil); - *a_box.borrow_mut() = cons(a_box); -} - -pub fn main() { - f(); -} diff --git a/src/test/run-pass/deref-lval.rs b/src/test/run-pass/deref-lval.rs index 4ccf6744d5c..d9b0940f80b 100644 --- a/src/test/run-pass/deref-lval.rs +++ b/src/test/run-pass/deref-lval.rs @@ -9,13 +9,10 @@ // except according to those terms. -extern crate debug; - use std::cell::Cell; -use std::gc::GC; pub fn main() { - let x = box(GC) Cell::new(5i); + let x = box Cell::new(5i); x.set(1000i); - println!("{:?}", x.get()); + println!("{}", x.get()); } diff --git a/src/test/run-pass/deref.rs b/src/test/run-pass/deref.rs index 12fc65cecb9..117b133a113 100644 --- a/src/test/run-pass/deref.rs +++ b/src/test/run-pass/deref.rs @@ -9,9 +9,7 @@ // except according to those terms. -use std::gc::{Gc, GC}; - pub fn main() { - let x: Gc = box(GC) 10; + let x: Box = box 10; let _y: int = *x; } diff --git a/src/test/run-pass/double-unbox.rs b/src/test/run-pass/double-unbox.rs deleted file mode 100644 index 0d5556a867b..00000000000 --- a/src/test/run-pass/double-unbox.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::Gc; - -struct Quux { - bar: int -} - -fn g(_i: int) { } -fn f(foo: Gc>) { g(foo.bar); } - -pub fn main() { } diff --git a/src/test/run-pass/drop-on-empty-block-exit.rs b/src/test/run-pass/drop-on-empty-block-exit.rs index 8add96d8ed7..c52549d286f 100644 --- a/src/test/run-pass/drop-on-empty-block-exit.rs +++ b/src/test/run-pass/drop-on-empty-block-exit.rs @@ -9,11 +9,9 @@ // except according to those terms. -use std::gc::{Gc, GC}; - -enum t { foo(Gc), } +enum t { foo(Box), } pub fn main() { - let tt = foo(box(GC) 10); + let tt = foo(box 10); match tt { foo(_z) => { } } } diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index 433c3b54224..3e22c833183 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -9,7 +9,6 @@ // except according to those terms. -use std::gc::Gc; use std::mem::size_of; trait Trait {} @@ -33,9 +32,8 @@ fn main() { assert_eq!(size_of::<&Trait>(), size_of::>()); assert_eq!(size_of::<&mut Trait>(), size_of::>()); - // Pointers - Box / Gc + // Pointers - Box assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::>(), size_of::>>()); // The optimization can't apply to raw pointers diff --git a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs index 7d8a3d3fb79..24fb503aea3 100644 --- a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs +++ b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs @@ -15,11 +15,9 @@ * represented with nullable pointers could be misoptimized in some cases. */ -use std::gc::{Gc, GC}; - -enum List { Nil, Cons(X, Gc>) } +enum List { Nil, Cons(X, Box>) } pub fn main() { - match Cons(10i, box(GC) Nil) { + match Cons(10i, box Nil) { Cons(10i, _) => {} Nil => {} _ => fail!() diff --git a/src/test/run-pass/evec-internal-boxes.rs b/src/test/run-pass/evec-internal-boxes.rs deleted file mode 100644 index 63e034c0eaa..00000000000 --- a/src/test/run-pass/evec-internal-boxes.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_assignment)] - -use std::gc::{Gc, GC}; - -pub fn main() { - let x : [Gc, ..5] = [box(GC) 1,box(GC) 2,box(GC) 3,box(GC) 4,box(GC) 5]; - let _y : [Gc, ..5] = [box(GC) 1,box(GC) 2,box(GC) 3,box(GC) 4,box(GC) 5]; - let mut z = [box(GC) 1,box(GC) 2,box(GC) 3,box(GC) 4,box(GC) 5]; - z = x; - assert_eq!(*z[0], 1); - assert_eq!(*z[4], 5); -} diff --git a/src/test/run-pass/export-non-interference.rs b/src/test/run-pass/export-non-interference.rs index 424a09227ec..94652e30fe6 100644 --- a/src/test/run-pass/export-non-interference.rs +++ b/src/test/run-pass/export-non-interference.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - -enum list_cell { cons(Gc>), nil } +enum list_cell { cons(Box>), nil } pub fn main() { } diff --git a/src/test/run-pass/expr-block-box.rs b/src/test/run-pass/expr-block-box.rs deleted file mode 100644 index 9b3d2028edf..00000000000 --- a/src/test/run-pass/expr-block-box.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -pub fn main() { let x = { box(GC) 100i }; assert!((*x == 100)); } diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs deleted file mode 100644 index dfcef171252..00000000000 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |Gc, Gc|: 'static -> bool; - -fn test_generic(expected: Gc, eq: compare) { - let actual: Gc = { expected }; - assert!((eq(expected, actual))); -} - -fn test_box() { - fn compare_box(b1: Gc, b2: Gc) -> bool { - println!("{}", *b1); - println!("{}", *b2); - return *b1 == *b2; - } - test_generic::(box(GC) true, compare_box); -} - -pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs deleted file mode 100644 index 547e7dfa911..00000000000 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -type compare<'a, T> = |T, T|: 'a -> bool; - -fn test_generic(expected: T, eq: compare) { - let actual: T = { expected.clone() }; - assert!((eq(expected, actual))); -} - -fn test_vec() { - fn compare_vec(v1: Gc, v2: Gc) -> bool { return v1 == v2; } - test_generic::>(box(GC) 1, compare_vec); -} - -pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-block-ref.rs b/src/test/run-pass/expr-block-ref.rs deleted file mode 100644 index 3d649b17b79..00000000000 --- a/src/test/run-pass/expr-block-ref.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -// Regression test for issue #388 -pub fn main() { let _x = { { box(GC) 10i } }; } diff --git a/src/test/run-pass/expr-elseif-ref.rs b/src/test/run-pass/expr-elseif-ref.rs deleted file mode 100644 index f0b9c85a53d..00000000000 --- a/src/test/run-pass/expr-elseif-ref.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// Make sure we drop the refs of the temporaries needed to return the -// values from the else if branch -pub fn main() { - let y: Gc = box(GC) 10u; - let _x = if false { y } else if true { y } else { y }; - assert_eq!(*y, 10u); -} diff --git a/src/test/run-pass/expr-elseif-ref2.rs b/src/test/run-pass/expr-elseif-ref2.rs deleted file mode 100644 index 9d4efea7e3d..00000000000 --- a/src/test/run-pass/expr-elseif-ref2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC}; - -// Regression test for issue #388 -pub fn main() { - let _x = if false { - box(GC) 0u - } else if true { - box(GC) 10u - } else { - box(GC) 0u - }; -} diff --git a/src/test/run-pass/expr-if-box.rs b/src/test/run-pass/expr-if-box.rs deleted file mode 100644 index 3def4571e13..00000000000 --- a/src/test/run-pass/expr-if-box.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// Tests for if as expressions returning boxed types -fn test_box() { - let rs = if true { box(GC) 100i } else { box(GC) 101i }; - assert_eq!(*rs, 100); -} - -fn test_str() { - let rs = if true { "happy".to_string() } else { "sad".to_string() }; - assert_eq!(rs, "happy".to_string()); -} - -pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs deleted file mode 100644 index 931f500a309..00000000000 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -type compare = |Gc, Gc|: 'static -> bool; - -fn test_generic(expected: Gc, not_expected: Gc, eq: compare) { - let actual: Gc = if true { expected } else { not_expected }; - assert!((eq(expected, actual))); -} - -fn test_box() { - fn compare_box(b1: Gc, b2: Gc) -> bool { return *b1 == *b2; } - test_generic::(box(GC) true, box(GC) false, compare_box); -} - -pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs deleted file mode 100644 index b8b8c9b89a8..00000000000 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |T, T|: 'static -> bool; - -fn test_generic(expected: T, not_expected: T, eq: compare) { - let actual: T = if true { expected.clone() } else { not_expected }; - assert!((eq(expected, actual))); -} - -fn test_vec() { - fn compare_box(v1: Gc, v2: Gc) -> bool { return v1 == v2; } - test_generic::>(box(GC) 1, box(GC) 2, compare_box); -} - -pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-match-box.rs b/src/test/run-pass/expr-match-box.rs deleted file mode 100644 index c2ba36006bd..00000000000 --- a/src/test/run-pass/expr-match-box.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -// Tests for match as expressions resulting in boxed types -fn test_box() { - let res = match true { true => { box(GC) 100i } _ => fail!("wat") }; - assert_eq!(*res, 100i); -} - -fn test_str() { - let res = match true { true => { "happy".to_string() }, - _ => fail!("not happy at all") }; - assert_eq!(res, "happy".to_string()); -} - -pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-match-generic-box1.rs b/src/test/run-pass/expr-match-generic-box1.rs deleted file mode 100644 index 97fa53b5e24..00000000000 --- a/src/test/run-pass/expr-match-generic-box1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |Gc, Gc|: 'static -> bool; - -fn test_generic(expected: Gc, eq: compare) { - let actual: Gc = match true { true => { expected }, _ => fail!() }; - assert!((eq(expected, actual))); -} - -fn test_box() { - fn compare_box(b1: Gc, b2: Gc) -> bool { return *b1 == *b2; } - test_generic::(box(GC) true, compare_box); -} - -pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-match-generic-box2.rs b/src/test/run-pass/expr-match-generic-box2.rs deleted file mode 100644 index fd8179c59a5..00000000000 --- a/src/test/run-pass/expr-match-generic-box2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |T, T|: 'static -> bool; - -fn test_generic(expected: T, eq: compare) { - let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; - assert!((eq(expected, actual))); -} - -fn test_vec() { - fn compare_box(v1: Gc, v2: Gc) -> bool { return v1 == v2; } - test_generic::>(box(GC) 1, compare_box); -} - -pub fn main() { test_vec(); } diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index cd0f3d6101a..e95c2034131 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -10,11 +10,10 @@ use std::cell::Cell; -use std::gc::{Gc, GC}; struct Point {x: int, y: int, z: int} -fn f(p: Gc>) { +fn f(p: &Cell) { assert!((p.get().z == 12)); p.set(Point {x: 10, y: 11, z: 13}); assert!((p.get().z == 13)); @@ -22,7 +21,7 @@ fn f(p: Gc>) { pub fn main() { let a: Point = Point {x: 10, y: 11, z: 12}; - let b: Gc> = box(GC) Cell::new(a); + let b: &Cell = &Cell::new(a); assert_eq!(b.get().z, 12); f(b); assert_eq!(a.z, 12); diff --git a/src/test/run-pass/fail-during-tld-destroy.rs b/src/test/run-pass/fail-during-tld-destroy.rs index 835f1fe4d4a..3faa30c4c8a 100644 --- a/src/test/run-pass/fail-during-tld-destroy.rs +++ b/src/test/run-pass/fail-during-tld-destroy.rs @@ -9,45 +9,25 @@ // except according to those terms. use std::task; -use std::gc::{GC, Gc}; -use std::cell::RefCell; static mut DROPS: uint = 0; -struct Foo(bool); +struct Foo; impl Drop for Foo { fn drop(&mut self) { - let Foo(fail) = *self; unsafe { DROPS += 1; } - if fail { fail!() } + fail!() } } -fn tld_fail(fail: bool) { - local_data_key!(foo: Foo); - foo.replace(Some(Foo(fail))); -} - -fn gc_fail(fail: bool) { - struct A { - inner: RefCell>>, - other: Foo, - } - let a = box(GC) A { - inner: RefCell::new(None), - other: Foo(fail), - }; - *a.inner.borrow_mut() = Some(a.clone()); -} - fn main() { let _ = task::try(proc() { - tld_fail(true); - gc_fail(false); + local_data_key!(foo: Foo); + foo.replace(Some(Foo)); }); unsafe { - assert_eq!(DROPS, 2); + assert_eq!(DROPS, 1); } } diff --git a/src/test/run-pass/gc-vec.rs b/src/test/run-pass/gc-vec.rs deleted file mode 100644 index 430ee16bc8a..00000000000 --- a/src/test/run-pass/gc-vec.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::gc::{GC}; - -fn main() { - // A fixed-size array allocated in a garbage-collected box - let x = box(GC) [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - assert_eq!(x[0], 1); - assert_eq!(x[6], 7); - assert_eq!(x[9], 10); - - let y = x; - assert!(*y == [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -} diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs deleted file mode 100644 index 325f6a2c854..00000000000 --- a/src/test/run-pass/generic-alias-box.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -extern crate debug; - -use std::gc::{Gc, GC}; - -fn id(t: T) -> T { return t; } - -pub fn main() { - let expected = box(GC) 100; - let actual = id::>(expected); - println!("{:?}", *actual); - assert_eq!(*expected, *actual); -} diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs deleted file mode 100644 index d5047eb8f86..00000000000 --- a/src/test/run-pass/generic-box.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn box_it(x: Box) -> Gc> { return box(GC) x; } - -struct Box {x: T, y: T, z: T} - -pub fn main() { - let x: Gc> = box_it::(Box{x: 1, y: 2, z: 3}); - assert_eq!(x.y, 2); -} diff --git a/src/test/run-pass/generic-drop-glue.rs b/src/test/run-pass/generic-drop-glue.rs deleted file mode 100644 index 2cc3a89459e..00000000000 --- a/src/test/run-pass/generic-drop-glue.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Pair { x: Gc, y: Gc } - -fn f(t: T) { let _t1: T = t; } - -pub fn main() { let x = Pair {x: box(GC) 10, y: box(GC) 12}; f(x); } diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs deleted file mode 100644 index 2c1ae5d9854..00000000000 --- a/src/test/run-pass/generic-exterior-box.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Recbox {x: Gc} - -fn reclift(t: T) -> Recbox { return Recbox {x: box(GC) t}; } - -pub fn main() { - let foo: int = 17; - let rbfoo: Recbox = reclift::(foo); - assert_eq!(*rbfoo.x, foo); -} diff --git a/src/test/run-pass/generic-fn-box.rs b/src/test/run-pass/generic-fn-box.rs deleted file mode 100644 index 2164b00e066..00000000000 --- a/src/test/run-pass/generic-fn-box.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -extern crate debug; - -use std::gc::{Gc, GC}; - -fn f(x: Gc) -> Gc { return x; } - -pub fn main() { let x = f(box(GC) 3i); println!("{:?}", *x); } diff --git a/src/test/run-pass/generic-ivec.rs b/src/test/run-pass/generic-ivec.rs deleted file mode 100644 index 68e7b98183b..00000000000 --- a/src/test/run-pass/generic-ivec.rs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn f(_v: Gc) { } -pub fn main() { f(box(GC) vec!(1i, 2, 3, 4, 5)); } diff --git a/src/test/run-pass/generic-recursive-tag.rs b/src/test/run-pass/generic-recursive-tag.rs index 6d81cea8b2f..d8777515cec 100644 --- a/src/test/run-pass/generic-recursive-tag.rs +++ b/src/test/run-pass/generic-recursive-tag.rs @@ -11,14 +11,12 @@ // ignore-pretty FIXME(#14193) -use std::gc::{Gc, GC}; - -enum list { cons(Gc, Gc>), nil, } +enum list { cons(Box, Box>), nil, } pub fn main() { let _a: list = - cons::(box(GC) 10, - box(GC) cons::(box(GC) 12, - box(GC) cons::(box(GC) 13, - box(GC) nil::))); + cons::(box 10, + box cons::(box 12, + box cons::(box 13, + box nil::))); } diff --git a/src/test/run-pass/generic-tag.rs b/src/test/run-pass/generic-tag.rs index 43cdf43ceb3..52e512e515c 100644 --- a/src/test/run-pass/generic-tag.rs +++ b/src/test/run-pass/generic-tag.rs @@ -11,11 +11,9 @@ #![allow(dead_assignment)] #![allow(unused_variable)] -use std::gc::{Gc, GC}; - -enum option { some(Gc), none, } +enum option { some(Box), none, } pub fn main() { - let mut a: option = some::(box(GC) 10); + let mut a: option = some::(box 10); a = none::; } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 78e17bb22bd..365070f704f 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -18,7 +18,6 @@ extern crate debug; use std::fmt; -use std::gc::GC; use std::io::MemWriter; use std::io; use std::str; @@ -50,7 +49,6 @@ pub fn main() { t!(format!("{:?}", 1i), "1"); t!(format!("{:?}", A), "A"); t!(format!("{:?}", ()), "()"); - t!(format!("{:?}", box(GC) (box 1i, "foo")), "box(GC) (box 1, \"foo\")"); // Various edge cases without formats t!(format!(""), ""); diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs index d6920b2e2fe..752e95f25dc 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -11,52 +11,43 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // Resources can't be copied, but storing into data structures counts // as a move unless the stored thing is used afterwards. -struct r { - i: Gc>, +struct r<'a> { + i: &'a Cell, } -struct Box { x: r } +struct BoxR<'a> { x: r<'a> } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { self.i.set(self.i.get() + 1) } } -fn r(i: Gc>) -> r { +fn r(i: &Cell) -> r { r { i: i } } -fn test_box() { - let i = box(GC) Cell::new(0i); - { - let _a = box(GC) r(i); - } - assert_eq!(i.get(), 1); -} - fn test_rec() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { - let _a = Box {x: r(i)}; + let _a = BoxR {x: r(i)}; } assert_eq!(i.get(), 1); } fn test_tag() { - enum t { - t0(r), + enum t<'a> { + t0(r<'a>), } - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { let _a = t0(r(i)); } @@ -64,7 +55,7 @@ fn test_tag() { } fn test_tup() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { let _a = (r(i), 0i); } @@ -72,17 +63,17 @@ fn test_tup() { } fn test_unique() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { let _a = box r(i); } assert_eq!(i.get(), 1); } -fn test_box_rec() { - let i = box(GC) Cell::new(0i); +fn test_unique_rec() { + let i = &Cell::new(0i); { - let _a = box(GC) Box { + let _a = box BoxR { x: r(i) }; } @@ -90,10 +81,9 @@ fn test_box_rec() { } pub fn main() { - test_box(); test_rec(); test_tag(); test_tup(); test_unique(); - test_box_rec(); + test_unique_rec(); } diff --git a/src/test/run-pass/issue-14082.rs b/src/test/run-pass/issue-14082.rs index 9aff6b91748..dd9a7c97c9a 100644 --- a/src/test/run-pass/issue-14082.rs +++ b/src/test/run-pass/issue-14082.rs @@ -8,21 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(globs)] #![allow(unused_imports, dead_code)] -use foo::GC; +use foo::Foo; mod foo { - pub use m::GC; // this should shadow d::GC + pub use m::Foo; // this should shadow d::Foo } mod m { - pub struct GC; + pub struct Foo; } mod d { - pub struct GC; + pub struct Foo; } fn main() {} diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs index 777210d2b04..84f046499e4 100644 --- a/src/test/run-pass/issue-2631-b.rs +++ b/src/test/run-pass/issue-2631-b.rs @@ -11,17 +11,16 @@ // aux-build:issue-2631-a.rs -extern crate collections; extern crate req; use req::request; use std::cell::RefCell; use std::collections::HashMap; -use std::gc::GC; +use std::rc::Rc; pub fn main() { - let v = vec!(box(GC) "hi".to_string()); + let v = vec!(Rc::new("hi".to_string())); let mut m: req::header_map = HashMap::new(); - m.insert("METHOD".to_string(), box(GC) RefCell::new(v)); + m.insert("METHOD".to_string(), Rc::new(RefCell::new(v))); request::(&m); } diff --git a/src/test/run-pass/issue-2708.rs b/src/test/run-pass/issue-2708.rs index e11cb28c65d..3ac4b874f3a 100644 --- a/src/test/run-pass/issue-2708.rs +++ b/src/test/run-pass/issue-2708.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - struct Font { fontbuf: uint, cairo_font: uint, @@ -31,5 +29,5 @@ fn Font() -> Font { } pub fn main() { - let _f = box(GC) Font(); + let _f = box Font(); } diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs index f7a91d11748..0d1cf1c3392 100644 --- a/src/test/run-pass/issue-2735-2.rs +++ b/src/test/run-pass/issue-2735-2.rs @@ -11,28 +11,27 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // This test should behave exactly like issue-2735-3 -struct defer { - b: Gc>, +struct defer<'a> { + b: &'a Cell, } #[unsafe_destructor] -impl Drop for defer { +impl<'a> Drop for defer<'a> { fn drop(&mut self) { self.b.set(true); } } -fn defer(b: Gc>) -> defer { +fn defer(b: &Cell) -> defer { defer { b: b } } pub fn main() { - let dtor_ran = box(GC) Cell::new(false); + let dtor_ran = &Cell::new(false); let _ = defer(dtor_ran); assert!(dtor_ran.get()); } diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs index 3650c3f9246..658183cf6ff 100644 --- a/src/test/run-pass/issue-2735-3.rs +++ b/src/test/run-pass/issue-2735-3.rs @@ -11,28 +11,27 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // This test should behave exactly like issue-2735-2 -struct defer { - b: Gc>, +struct defer<'a> { + b: &'a Cell, } #[unsafe_destructor] -impl Drop for defer { +impl<'a> Drop for defer<'a> { fn drop(&mut self) { self.b.set(true); } } -fn defer(b: Gc>) -> defer { +fn defer(b: &Cell) -> defer { defer { b: b } } pub fn main() { - let dtor_ran = box(GC) Cell::new(false); + let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); } diff --git a/src/test/run-pass/issue-3012-2.rs b/src/test/run-pass/issue-3012-2.rs index 96e60dab3c9..aa2ce824822 100644 --- a/src/test/run-pass/issue-3012-2.rs +++ b/src/test/run-pass/issue-3012-2.rs @@ -14,10 +14,9 @@ extern crate socketlib; extern crate libc; -use std::gc::GC; use socketlib::socket; pub fn main() { let fd: libc::c_int = 1 as libc::c_int; - let _sock = box(GC) socket::socket_handle(fd); + let _sock = box socket::socket_handle(fd); } diff --git a/src/test/run-pass/issue-3121.rs b/src/test/run-pass/issue-3121.rs index 24ffd416499..6b320e14746 100644 --- a/src/test/run-pass/issue-3121.rs +++ b/src/test/run-pass/issue-3121.rs @@ -9,13 +9,11 @@ // except according to those terms. -use std::gc::{Gc, GC}; - enum side { mayo, catsup, vinegar } enum order { hamburger, fries(side), shake } enum meal { to_go(order), for_here(order) } -fn foo(m: Gc, cond: bool) { +fn foo(m: Box, cond: bool) { match *m { to_go(_) => { } for_here(_) if cond => {} @@ -26,5 +24,5 @@ fn foo(m: Gc, cond: bool) { } pub fn main() { - foo(box(GC) for_here(hamburger), true) + foo(box for_here(hamburger), true) } diff --git a/src/test/run-pass/issue-3447.rs b/src/test/run-pass/issue-3447.rs index 612e0a07dac..4ebf981e4ee 100644 --- a/src/test/run-pass/issue-3447.rs +++ b/src/test/run-pass/issue-3447.rs @@ -10,13 +10,12 @@ use std::cell::RefCell; -use std::gc::{Gc, GC}; static S: &'static str = "str"; struct list { element: T, - next: Option>>> + next: Option>>> } impl list { @@ -26,7 +25,7 @@ impl list { next: None }; - self.next = Some(box(GC) RefCell::new(newList)); + self.next = Some(box RefCell::new(newList)); } } diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index b8a34b75181..e59cf9f77fa 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -9,18 +9,15 @@ // except according to those terms. -extern crate debug; - -use std::gc::{Gc, GC}; - +#[deriving(Show)] enum Token { - Text(Gc), - ETag(Gc> , Gc), - UTag(Gc> , Gc), - Section(Gc> , bool, Gc>, Gc, - Gc, Gc, Gc, Gc), - IncompleteSection(Gc> , bool, Gc, bool), - Partial(Gc, Gc, Gc), + Text(String), + ETag(Vec, String), + UTag(Vec, String), + Section(Vec, bool, Vec, String, + String, String, String, String), + IncompleteSection(Vec, bool, String, bool), + Partial(String, String, String), } fn check_strs(actual: &str, expected: &str) -> bool @@ -39,13 +36,13 @@ pub fn main() // assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())), // "ETag(@~[ ~\"foo\" ], @~\"bar\")")); - let t = Text(box(GC) "foo".to_string()); - let u = Section(box(GC) vec!("alpha".to_string()), - true, - box(GC) vec!(t), - box(GC) "foo".to_string(), - box(GC) "foo".to_string(), box(GC) "foo".to_string(), box(GC) "foo".to_string(), - box(GC) "foo".to_string()); - let v = format!("{:?}", u); // this is the line that causes the seg fault + let t = Text("foo".to_string()); + let u = Section(vec!["alpha".to_string()], + true, + vec![t], + "foo".to_string(), + "foo".to_string(), "foo".to_string(), "foo".to_string(), + "foo".to_string()); + let v = format!("{}", u); // this is the line that causes the seg fault assert!(v.len() > 0); } diff --git a/src/test/run-pass/issue-5884.rs b/src/test/run-pass/issue-5884.rs index 93f8ebf02ac..4010c31eed5 100644 --- a/src/test/run-pass/issue-5884.rs +++ b/src/test/run-pass/issue-5884.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - pub struct Foo { a: int, } @@ -20,7 +18,7 @@ struct Bar<'a> { b: &'a Foo, } -fn check(a: Gc) { +fn check(a: Box) { let _ic = Bar{ b: &*a, a: box None }; } diff --git a/src/test/run-pass/issue-6117.rs b/src/test/run-pass/issue-6117.rs index e124b2efe29..7eaaa5ea74e 100644 --- a/src/test/run-pass/issue-6117.rs +++ b/src/test/run-pass/issue-6117.rs @@ -9,12 +9,10 @@ // except according to those terms. -use std::gc::GC; - enum Either { Left(T), Right(U) } pub fn main() { - match Left(box(GC) 17i) { + match Left(box 17i) { Right(()) => {} _ => {} } diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index f2dcaa4a31e..3fff58410a4 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -12,8 +12,6 @@ extern crate debug; -use std::gc::GC; - fn assert_repr_eq(obj : T, expected : String) { assert_eq!(expected, format!("{:?}", obj)); } @@ -23,12 +21,10 @@ pub fn main() { let tf = [true, false]; let x = [(), ()]; let slice = x[0..1]; - let z = box(GC) x; assert_repr_eq(abc, "[1, 2, 3]".to_string()); assert_repr_eq(tf, "[true, false]".to_string()); assert_repr_eq(x, "[(), ()]".to_string()); assert_repr_eq(slice, "&[()]".to_string()); assert_repr_eq(&x, "&[(), ()]".to_string()); - assert_repr_eq(z, "box(GC) [(), ()]".to_string()); } diff --git a/src/test/run-pass/issue-8983.rs b/src/test/run-pass/issue-8983.rs deleted file mode 100644 index 1291f0b6cd1..00000000000 --- a/src/test/run-pass/issue-8983.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -fn main() { - fn f(_: proc()) {} - fn eat(_: T) {} - - let x = box(GC) 1i; - f(proc() { eat(x) }); -} diff --git a/src/test/run-pass/issue-979.rs b/src/test/run-pass/issue-979.rs index abe6a2d9ee6..919f0aae38e 100644 --- a/src/test/run-pass/issue-979.rs +++ b/src/test/run-pass/issue-979.rs @@ -11,27 +11,26 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{GC, Gc}; -struct r { - b: Gc>, +struct r<'a> { + b: &'a Cell, } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { self.b.set(self.b.get() + 1); } } -fn r(b: Gc>) -> r { +fn r(b: &Cell) -> r { r { b: b } } pub fn main() { - let b = box(GC) Cell::new(0); + let b = &Cell::new(0); { let _p = Some(r(b)); } diff --git a/src/test/run-pass/issue-980.rs b/src/test/run-pass/issue-980.rs deleted file mode 100644 index 1083f1b3c71..00000000000 --- a/src/test/run-pass/issue-980.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum maybe_pointy { - no_pointy, - yes_pointy(Gc>), -} - -struct Pointy { - x: maybe_pointy -} - -pub fn main() { - let m = box(GC) RefCell::new(Pointy { x : no_pointy }); - *m.borrow_mut() = Pointy { - x: yes_pointy(m) - }; -} diff --git a/src/test/run-pass/leak-box-as-tydesc.rs b/src/test/run-pass/leak-box-as-tydesc.rs deleted file mode 100644 index 57b9b2494f5..00000000000 --- a/src/test/run-pass/leak-box-as-tydesc.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn leaky(_t: T) { } - -pub fn main() { let x = box(GC) 10; leaky::>(x); } diff --git a/src/test/run-pass/leak-tag-copy.rs b/src/test/run-pass/leak-tag-copy.rs deleted file mode 100644 index 3be122b38fa..00000000000 --- a/src/test/run-pass/leak-tag-copy.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_assignment)] -#![allow(unused_variable)] - -use std::gc::{Gc, GC}; - -enum t { a, b(Gc), } - -pub fn main() { let mut x = b(box(GC) 10); x = a; } diff --git a/src/test/run-pass/list.rs b/src/test/run-pass/list.rs index bbb3ce2f2e1..7d0778b6859 100644 --- a/src/test/run-pass/list.rs +++ b/src/test/run-pass/list.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::{Gc, GC}; +enum list { cons(int, Box), nil, } -enum list { cons(int, Gc), nil, } - -pub fn main() { cons(10, box(GC) cons(11, box(GC) cons(12, box(GC) nil))); } +pub fn main() { cons(10, box cons(11, box cons(12, box nil))); } diff --git a/src/test/run-pass/mlist.rs b/src/test/run-pass/mlist.rs deleted file mode 100644 index ee91ae124b8..00000000000 --- a/src/test/run-pass/mlist.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -enum mlist { cons(int, Gc), nil, } - -pub fn main() { cons(10, box(GC) cons(11, box(GC) cons(12, box(GC) nil))); } diff --git a/src/test/run-pass/move-1.rs b/src/test/run-pass/move-1.rs deleted file mode 100644 index 6f4ffa51a46..00000000000 --- a/src/test/run-pass/move-1.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Triple { x: int, y: int, z: int } - -fn test(x: bool, foo: Gc) -> int { - let bar = foo; - let mut y: Gc; - y = bar; - if x { y = bar; } else { y = box(GC) Triple{x: 4, y: 5, z: 6}; } - return y.y; -} - -pub fn main() { - let x = box(GC) Triple {x: 1, y: 2, z: 3}; - assert_eq!(test(true, x), 2); - assert_eq!(test(true, x), 2); - assert_eq!(test(true, x), 2); - assert_eq!(test(false, x), 5); -} diff --git a/src/test/run-pass/move-2.rs b/src/test/run-pass/move-2.rs index bcc67738dd4..04540c2f35b 100644 --- a/src/test/run-pass/move-2.rs +++ b/src/test/run-pass/move-2.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - struct X { x: int, y: int, z: int } -pub fn main() { let x = box(GC) X {x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } +pub fn main() { let x = box X {x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } diff --git a/src/test/run-pass/move-3.rs b/src/test/run-pass/move-3.rs deleted file mode 100644 index 21a7d57b563..00000000000 --- a/src/test/run-pass/move-3.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Triple { x: int, y: int, z: int } - -fn test(x: bool, foo: Gc) -> int { - let bar = foo; - let mut y: Gc; - if x { y = bar; } else { y = box(GC) Triple{x: 4, y: 5, z: 6}; } - return y.y; -} - -pub fn main() { - let x = box(GC) Triple{x: 1, y: 2, z: 3}; - for _i in range(0u, 10000u) { - assert_eq!(test(true, x), 2); - } - assert_eq!(test(false, x), 5); -} diff --git a/src/test/run-pass/move-4.rs b/src/test/run-pass/move-4.rs index 984cef55998..5e5d01ae6ee 100644 --- a/src/test/run-pass/move-4.rs +++ b/src/test/run-pass/move-4.rs @@ -9,11 +9,9 @@ // except according to those terms. -use std::gc::{GC, Gc}; - struct Triple { a: int, b: int, c: int } -fn test(foo: Gc) -> Gc { +fn test(foo: Box) -> Box { let foo = foo; let bar = foo; let baz = bar; @@ -22,7 +20,7 @@ fn test(foo: Gc) -> Gc { } pub fn main() { - let x = box(GC) Triple{a: 1, b: 2, c: 3}; + let x = box Triple{a: 1, b: 2, c: 3}; let y = test(x); assert_eq!(y.c, 3); } diff --git a/src/test/run-pass/move-arg-2.rs b/src/test/run-pass/move-arg-2.rs index d00cdcca3e3..840a3c2a6ee 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.rs @@ -9,15 +9,13 @@ // except according to those terms. -use std::gc::{Gc, GC}; - -fn test(foo: Gc>) { assert!((*foo.get(0) == 10)); } +fn test(foo: Box>) { assert!((*foo.get(0) == 10)); } pub fn main() { - let x = box(GC) vec!(10); + let x = box vec!(10); // Test forgetting a local by move-in test(x); // Test forgetting a temporary by move-in. - test(box(GC) vec!(10)); + test(box vec!(10)); } diff --git a/src/test/run-pass/mutable-vec-drop.rs b/src/test/run-pass/mutable-vec-drop.rs deleted file mode 100644 index 665303ac487..00000000000 --- a/src/test/run-pass/mutable-vec-drop.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_mut)] - -use std::gc::{Gc, GC}; - -struct Pair { a: int, b: int} - -pub fn main() { - // This just tests whether the vec leaks its members. - let mut _pvec: Vec> = - vec!(box(GC) Pair{a: 1, b: 2}, - box(GC) Pair{a: 3, b: 4}, - box(GC) Pair{a: 5, b: 6}); -} diff --git a/src/test/run-pass/mutual-recursion-group.rs b/src/test/run-pass/mutual-recursion-group.rs index 18f332dbb97..8444a632fe8 100644 --- a/src/test/run-pass/mutual-recursion-group.rs +++ b/src/test/run-pass/mutual-recursion-group.rs @@ -9,14 +9,12 @@ // except according to those terms. -use std::gc::Gc; - enum colour { red, green, blue, } -enum tree { children(Gc), leaf(colour), } +enum tree { children(Box), leaf(colour), } -enum list { cons(Gc, Gc), nil, } +enum list { cons(Box, Box), nil, } -enum small_list { kons(int, Gc), neel, } +enum small_list { kons(int, Box), neel, } pub fn main() { } diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index f61a8837e2c..991d0ecdc87 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -11,9 +11,8 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests that the new `box` syntax works with unique pointers and GC pointers. +// Tests that the new `box` syntax works with unique pointers. -use std::gc::{Gc, GC}; use std::boxed::{Box, HEAP}; struct Structure { @@ -24,12 +23,6 @@ struct Structure { pub fn main() { let x: Box = box(HEAP) 2i; let y: Box = box 2i; - let z: Gc = box(GC) 2i; - let a: Gc = box(GC) Structure { - x: 10, - y: 20, - }; let b: Box = box()(1i + 2); let c = box()(3i + 4); - let d = box(GC)(5i + 6); } diff --git a/src/test/run-pass/newtype-struct-drop-run.rs b/src/test/run-pass/newtype-struct-drop-run.rs index 50971806a87..8c35abad7f1 100644 --- a/src/test/run-pass/newtype-struct-drop-run.rs +++ b/src/test/run-pass/newtype-struct-drop-run.rs @@ -13,12 +13,11 @@ // Make sure the destructor is run for newtype structs. use std::cell::Cell; -use std::gc::{Gc, GC}; -struct Foo(Gc>); +struct Foo<'a>(&'a Cell); #[unsafe_destructor] -impl Drop for Foo { +impl<'a> Drop for Foo<'a> { fn drop(&mut self) { let Foo(i) = *self; i.set(23); @@ -26,7 +25,7 @@ impl Drop for Foo { } pub fn main() { - let y = box(GC) Cell::new(32); + let y = &Cell::new(32); { let _x = Foo(y); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index a7d52b87e55..0c66b139e7c 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -11,7 +11,6 @@ #![feature(macro_rules)] use std::{option, mem}; -use std::gc::{Gc, GC}; // Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions, // which "says that a destructor applied to an object built from a constructor @@ -76,7 +75,6 @@ macro_rules! check_type { pub fn main() { check_type!(&17: &int); check_type!(box 18: Box); - check_type!(box(GC) 19: Gc); check_type!("foo".to_string(): String); check_type!(vec!(20, 22): Vec ); let mint: uint = unsafe { mem::transmute(main) }; diff --git a/src/test/run-pass/nullable-pointer-size.rs b/src/test/run-pass/nullable-pointer-size.rs index 9dd65bdcb26..5708310abad 100644 --- a/src/test/run-pass/nullable-pointer-size.rs +++ b/src/test/run-pass/nullable-pointer-size.rs @@ -11,7 +11,6 @@ #![feature(macro_rules)] use std::mem; -use std::gc::Gc; enum E { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) } struct S(int, T); @@ -40,6 +39,5 @@ macro_rules! check_type { pub fn main() { check_type!(&'static int); check_type!(Box); - check_type!(Gc); check_type!(extern fn()); } diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs deleted file mode 100644 index 60c46d17b06..00000000000 --- a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// Test invoked `&self` methods on owned objects where the values -// closed over contain managed values. This implies that the boxes -// will have headers that must be skipped over. - -trait FooTrait { - fn foo(&self) -> uint; -} - -struct BarStruct { - x: Gc -} - -impl FooTrait for BarStruct { - fn foo(&self) -> uint { - *self.x - } -} - -pub fn main() { - let foos: Vec> = vec!( - box BarStruct{ x: box(GC) 0 } as Box, - box BarStruct{ x: box(GC) 1 } as Box, - box BarStruct{ x: box(GC) 2 } as Box - ); - - for i in range(0u, foos.len()) { - assert_eq!(i, foos.get(i).foo()); - } -} diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index a6730d67ce0..8bdae89e523 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -11,16 +11,14 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{GC, Gc}; -struct dtor { - x: Gc>, +struct dtor<'a> { + x: &'a Cell, } #[unsafe_destructor] -impl Drop for dtor { +impl<'a> Drop for dtor<'a> { fn drop(&mut self) { - // abuse access to shared mutable state to write this code self.x.set(self.x.get() - 1); } } @@ -33,7 +31,7 @@ fn unwrap(o: Option) -> T { } pub fn main() { - let x = box(GC) Cell::new(1); + let x = &Cell::new(1); { let b = Some(dtor { x:x }); diff --git a/src/test/run-pass/output-slot-variants.rs b/src/test/run-pass/output-slot-variants.rs index 34dccb81865..8a10cc8c1ef 100644 --- a/src/test/run-pass/output-slot-variants.rs +++ b/src/test/run-pass/output-slot-variants.rs @@ -11,30 +11,28 @@ #![allow(dead_assignment)] #![allow(unused_variable)] -use std::gc::{Gc, GC}; - struct A { a: int, b: int } -struct Abox { a: Gc, b: Gc } +struct Abox { a: Box, b: Box } -fn ret_int_i() -> int { return 10; } +fn ret_int_i() -> int { 10 } -fn ret_ext_i() -> Gc { return box(GC) 10; } +fn ret_ext_i() -> Box { box 10 } -fn ret_int_rec() -> A { return A {a: 10, b: 10}; } +fn ret_int_rec() -> A { A {a: 10, b: 10} } -fn ret_ext_rec() -> Gc { return box(GC) A {a: 10, b: 10}; } +fn ret_ext_rec() -> Box { box A {a: 10, b: 10} } -fn ret_ext_mem() -> Abox { return Abox {a: box(GC) 10, b: box(GC) 10}; } +fn ret_ext_mem() -> Abox { Abox {a: box 10, b: box 10} } -fn ret_ext_ext_mem() -> Gc { box(GC) Abox{a: box(GC) 10, b: box(GC) 10} } +fn ret_ext_ext_mem() -> Box { box Abox{a: box 10, b: box 10} } pub fn main() { let mut int_i: int; - let mut ext_i: Gc; + let mut ext_i: Box; let mut int_rec: A; - let mut ext_rec: Gc; + let mut ext_rec: Box; let mut ext_mem: Abox; - let mut ext_ext_mem: Gc; + let mut ext_ext_mem: Box; int_i = ret_int_i(); // initializing int_i = ret_int_i(); // non-initializing diff --git a/src/test/run-pass/packed-struct-size.rs b/src/test/run-pass/packed-struct-size.rs index cfea444d7ff..e6bfc8ec1a5 100644 --- a/src/test/run-pass/packed-struct-size.rs +++ b/src/test/run-pass/packed-struct-size.rs @@ -10,7 +10,6 @@ use std::mem; -use std::gc::Gc; #[repr(packed)] struct S4 { @@ -48,7 +47,7 @@ struct S7_Option { a: f32, b: u8, c: u16, - d: Option> + d: Option> } // Placing packed structs in statics should work @@ -62,5 +61,5 @@ pub fn main() { assert_eq!(mem::size_of::(), 5); assert_eq!(mem::size_of::(), 13); assert_eq!(mem::size_of::(), 3 + mem::size_of::()); - assert_eq!(mem::size_of::(), 7 + mem::size_of::>>()); + assert_eq!(mem::size_of::(), 7 + mem::size_of::>>()); } diff --git a/src/test/run-pass/packed-tuple-struct-size.rs b/src/test/run-pass/packed-tuple-struct-size.rs index f23166288fb..8967b07ca88 100644 --- a/src/test/run-pass/packed-tuple-struct-size.rs +++ b/src/test/run-pass/packed-tuple-struct-size.rs @@ -9,7 +9,6 @@ // except according to those terms. -use std::gc::Gc; use std::mem; #[repr(packed)] @@ -30,7 +29,7 @@ enum Foo { struct S3_Foo(u8, u16, Foo); #[repr(packed)] -struct S7_Option(f32, u8, u16, Option>); +struct S7_Option(f32, u8, u16, Option>); pub fn main() { assert_eq!(mem::size_of::(), 4); @@ -43,5 +42,5 @@ pub fn main() { 3 + mem::size_of::()); assert_eq!(mem::size_of::(), - 7 + mem::size_of::>>()); + 7 + mem::size_of::>>()); } diff --git a/src/test/run-pass/pass-by-copy.rs b/src/test/run-pass/pass-by-copy.rs deleted file mode 100644 index 88209192422..00000000000 --- a/src/test/run-pass/pass-by-copy.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -extern crate debug; - -use std::gc::{GC, Gc}; - -fn magic(x: A) { println!("{:?}", x); } -fn magic2(x: Gc) { println!("{:?}", x); } - -struct A { a: Gc } - -pub fn main() { - let a = A {a: box(GC) 10}; - let b = box(GC) 10; - magic(a); magic(A {a: box(GC) 20}); - magic2(b); magic2(box(GC) 20); -} diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index b856386e1d3..8ad2dbc1acb 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - trait get { fn get(self) -> int; } @@ -25,15 +23,6 @@ impl<'a> get for &'a int { } pub fn main() { - let x = box(GC) 6; - let y = x.get(); - assert_eq!(y, 6); - - let x = box(GC) 6; - let y = x.get(); - println!("y={}", y); - assert_eq!(y, 6); - let x = box 6; let y = x.get(); println!("y={}", y); diff --git a/src/test/run-pass/regions-borrow-at.rs b/src/test/run-pass/regions-borrow-at.rs index 15206f1c386..9a758c5d8ad 100644 --- a/src/test/run-pass/regions-borrow-at.rs +++ b/src/test/run-pass/regions-borrow-at.rs @@ -9,14 +9,12 @@ // except according to those terms. -use std::gc::GC; - fn foo(x: &uint) -> uint { *x } pub fn main() { - let p = box(GC) 22u; + let p = box 22u; let r = foo(&*p); println!("r={}", r); assert_eq!(r, 22u); diff --git a/src/test/run-pass/regions-escape-into-other-fn.rs b/src/test/run-pass/regions-escape-into-other-fn.rs index 09d9008c0b6..5b0b7cc5b4e 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -9,12 +9,10 @@ // except according to those terms. -use std::gc::GC; - fn foo(x: &uint) -> &uint { x } fn bar(x: &uint) -> uint { *x } pub fn main() { - let p = box(GC) 3u; + let p = box 3u; assert_eq!(bar(foo(&*p)), 3); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 4d4417189c9..1ecaf41702e 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::gc::GC; - fn borrow(x: &T) -> &T {x} pub fn main() { - let x = box(GC) 3i; + let x = box 3i; loop { let y = borrow(&*x); assert_eq!(*x, *y); diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index 4c021b18ad8..d3dbca53f60 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - struct Point {x: int, y: int} fn x_coord(p: &Point) -> &int { @@ -18,7 +16,7 @@ fn x_coord(p: &Point) -> &int { } pub fn main() { - let p = box(GC) Point {x: 3, y: 4}; + let p = box Point {x: 3, y: 4}; let xc = x_coord(&*p); assert_eq!(*xc, 3); } diff --git a/src/test/run-pass/resource-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index 48022fefbbd..5ea22ae76c2 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -10,36 +10,34 @@ #![feature(unsafe_destructor)] -extern crate debug; - use std::cell::Cell; -use std::gc::{Gc, GC}; -struct r { - i: Gc>, +#[deriving(Show)] +struct r<'a> { + i: &'a Cell, } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { self.i.set(self.i.get() + 1); } } -fn r(i: Gc>) -> r { +fn r(i: &Cell) -> r { r { i: i } } pub fn main() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); // Even though these look like copies, they are guaranteed not to be { let a = r(i); let b = (a, 10i); let (c, _d) = b; - println!("{:?}", c); + println!("{}", c); } assert_eq!(i.get(), 1); } diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index ba6a285d652..71bf6cc6261 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -11,31 +11,30 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{GC, Gc}; -struct shrinky_pointer { - i: Gc>>, +struct shrinky_pointer<'a> { + i: &'a Cell, } #[unsafe_destructor] -impl Drop for shrinky_pointer { +impl<'a> Drop for shrinky_pointer<'a> { fn drop(&mut self) { println!("Hello!"); self.i.set(self.i.get() - 1); } } -impl shrinky_pointer { +impl<'a> shrinky_pointer<'a> { pub fn look_at(&self) -> int { return self.i.get(); } } -fn shrinky_pointer(i: Gc>>) -> shrinky_pointer { +fn shrinky_pointer(i: &Cell) -> shrinky_pointer { shrinky_pointer { i: i } } pub fn main() { - let my_total = box(GC) box(GC) Cell::new(10); + let my_total = &Cell::new(10); { let pt = shrinky_pointer(my_total); assert!((pt.look_at() == 10)); } println!("my_total = {}", my_total.get()); assert_eq!(my_total.get(), 9); diff --git a/src/test/run-pass/resource-in-struct.rs b/src/test/run-pass/resource-in-struct.rs index fd1efe1a20e..8e798fc6a0d 100644 --- a/src/test/run-pass/resource-in-struct.rs +++ b/src/test/run-pass/resource-in-struct.rs @@ -14,17 +14,16 @@ // variant use std::cell::Cell; -use std::gc::{Gc, GC}; -type closable = Gc>; +type closable<'a> = &'a Cell; -struct close_res { - i: closable, +struct close_res<'a> { + i: closable<'a>, } #[unsafe_destructor] -impl Drop for close_res { +impl<'a> Drop for close_res<'a> { fn drop(&mut self) { self.i.set(false); } @@ -41,7 +40,7 @@ enum option { none, some(T), } fn sink(_res: option) { } pub fn main() { - let c = box(GC) Cell::new(true); + let c = &Cell::new(true); sink(none); sink(some(close_res(c))); assert!(!c.get()); diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index b58db67c0ac..2d6da26df52 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -9,30 +9,26 @@ // except according to those terms. -extern crate debug; - // Exercises a bug in the shape code that was exposed // on x86_64: when there is an enum embedded in an // interior record which is then itself interior to // something else, shape calculations were off. -use std::gc::{Gc, GC}; - -#[deriving(Clone)] +#[deriving(Clone, Show)] enum opt_span { //hack (as opposed to option), to make `span` compile os_none, - os_some(Gc), + os_some(Box), } -#[deriving(Clone)] +#[deriving(Clone, Show)] struct Span { lo: uint, hi: uint, expanded_from: opt_span, } -#[deriving(Clone)] +#[deriving(Clone, Show)] struct Spanned { data: T, span: Span, @@ -40,17 +36,17 @@ struct Spanned { type ty_ = uint; -#[deriving(Clone)] +#[deriving(Clone, Show)] struct Path_ { global: bool, idents: Vec , - types: Vec>, + types: Vec>, } type path = Spanned; type ty = Spanned; -#[deriving(Clone)] +#[deriving(Clone, Show)] struct X { sp: Span, path: path, @@ -58,14 +54,14 @@ struct X { pub fn main() { let sp: Span = Span {lo: 57451u, hi: 57542u, expanded_from: os_none}; - let t: Gc = box(GC) Spanned { data: 3u, span: sp }; + let t: Box = box Spanned { data: 3u, span: sp.clone() }; let p_: Path_ = Path_ { global: true, idents: vec!("hi".to_string()), types: vec!(t), }; - let p: path = Spanned { data: p_, span: sp }; + let p: path = Spanned { data: p_, span: sp.clone() }; let x = X { sp: sp, path: p }; - println!("{:?}", x.path.clone()); - println!("{:?}", x.clone()); + println!("{}", x.path.clone()); + println!("{}", x.clone()); } diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index fcce05a7b09..41a9e6e53f2 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -13,22 +13,21 @@ // Don't try to clean up uninitialized locals use std::task; -use std::gc::{Gc}; -fn test_break() { loop { let _x: Gc = break; } } +fn test_break() { loop { let _x: Box = break; } } -fn test_cont() { let mut i = 0i; while i < 1 { i += 1; let _x: Gc = continue; } } +fn test_cont() { let mut i = 0i; while i < 1 { i += 1; let _x: Box = continue; } } -fn test_ret() { let _x: Gc = return; } +fn test_ret() { let _x: Box = return; } fn test_fail() { - fn f() { let _x: Gc = fail!(); } + fn f() { let _x: Box = fail!(); } task::try(proc() f() ); } fn test_fail_indirect() { fn f() -> ! { fail!(); } - fn g() { let _x: Gc = f(); } + fn g() { let _x: Box = f(); } task::try(proc() g() ); } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs deleted file mode 100644 index 30acf07ae60..00000000000 --- a/src/test/run-pass/trait-cast.rs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-pretty FIXME(#14193) - - -// Test cyclic detector when using trait instances. - -use std::cell::RefCell; -use std::gc::{GC, Gc}; - -struct Tree(Gc>); -struct TreeR { - left: Option, - right: Option, - val: Box -} - -trait to_str { - fn to_str_(&self) -> String; -} - -impl to_str for Option { - fn to_str_(&self) -> String { - match *self { - None => { "none".to_string() } - Some(ref t) => format!("some({})", t.to_str_()), - } - } -} - -impl to_str for int { - fn to_str_(&self) -> String { - self.to_string() - } -} - -impl to_str for Tree { - fn to_str_(&self) -> String { - let Tree(t) = *self; - let this = t.borrow(); - let (l, r) = (this.left, this.right); - let val = &this.val; - format!("[{}, {}, {}]", val.to_str_(), l.to_str_(), r.to_str_()) - } -} - -fn foo(x: T) -> String { x.to_str_() } - -pub fn main() { - let t1 = Tree(box(GC) RefCell::new(TreeR{left: None, - right: None, - val: box 1i as Box})); - let t2 = Tree(box(GC) RefCell::new(TreeR{left: Some(t1), - right: Some(t1), - val: box 2i as Box})); - let expected = - "[2, some([1, none, none]), some([1, none, none])]".to_string(); - assert!(t2.to_str_() == expected); - assert!(foo(t2) == expected); - - { - let Tree(t1_) = t1; - let mut t1 = t1_.borrow_mut(); - t1.left = Some(t2); // create cycle - } -} diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 41a8ca33a2a..7265ddf6615 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - fn p_foo(_pinned: T) { } fn s_foo(_shared: T) { } fn u_foo(_unique: T) { } @@ -31,15 +29,11 @@ fn r(i:int) -> r { pub fn main() { p_foo(r(10)); - p_foo(box(GC) r(10)); p_foo(box r(10)); - p_foo(box(GC) 10i); p_foo(box 10i); p_foo(10i); - s_foo(box(GC) r(10)); - s_foo(box(GC) 10i); s_foo(box 10i); s_foo(10i); diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index 0cd6210e13c..6d8e7d1aaf3 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -12,17 +12,15 @@ // Example from lkuper's intern talk, August 2012 -- now with static // methods! -use std::gc::{GC, Gc}; - trait Equal { - fn isEq(a: Self, b: Self) -> bool; + fn isEq(a: &Self, b: &Self) -> bool; } enum Color { cyan, magenta, yellow, black } impl Equal for Color { - fn isEq(a: Color, b: Color) -> bool { - match (a, b) { + fn isEq(a: &Color, b: &Color) -> bool { + match (*a, *b) { (cyan, cyan) => { true } (magenta, magenta) => { true } (yellow, yellow) => { true } @@ -34,15 +32,15 @@ impl Equal for Color { enum ColorTree { leaf(Color), - branch(Gc, Gc) + branch(Box, Box) } impl Equal for ColorTree { - fn isEq(a: ColorTree, b: ColorTree) -> bool { + fn isEq(a: &ColorTree, b: &ColorTree) -> bool { match (a, b) { - (leaf(x), leaf(y)) => { Equal::isEq(x, y) } - (branch(l1, r1), branch(l2, r2)) => { - Equal::isEq(*l1, *l2) && Equal::isEq(*r1, *r2) + (&leaf(x), &leaf(y)) => { Equal::isEq(&x, &y) } + (&branch(ref l1, ref r1), &branch(ref l2, ref r2)) => { + Equal::isEq(&**l1, &**l2) && Equal::isEq(&**r1, &**r2) } _ => { false } } @@ -50,19 +48,19 @@ impl Equal for ColorTree { } pub fn main() { - assert!(Equal::isEq(cyan, cyan)); - assert!(Equal::isEq(magenta, magenta)); - assert!(!Equal::isEq(cyan, yellow)); - assert!(!Equal::isEq(magenta, cyan)); + assert!(Equal::isEq(&cyan, &cyan)); + assert!(Equal::isEq(&magenta, &magenta)); + assert!(!Equal::isEq(&cyan, &yellow)); + assert!(!Equal::isEq(&magenta, &cyan)); - assert!(Equal::isEq(leaf(cyan), leaf(cyan))); - assert!(!Equal::isEq(leaf(cyan), leaf(yellow))); + assert!(Equal::isEq(&leaf(cyan), &leaf(cyan))); + assert!(!Equal::isEq(&leaf(cyan), &leaf(yellow))); - assert!(Equal::isEq(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)), - branch(box(GC) leaf(magenta), box(GC) leaf(cyan)))); + assert!(Equal::isEq(&branch(box leaf(magenta), box leaf(cyan)), + &branch(box leaf(magenta), box leaf(cyan)))); - assert!(!Equal::isEq(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)), - branch(box(GC) leaf(magenta), box(GC) leaf(magenta)))); + assert!(!Equal::isEq(&branch(box leaf(magenta), box leaf(cyan)), + &branch(box leaf(magenta), box leaf(magenta)))); println!("Assertions all succeeded!"); } diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index 0a77824cf47..cbb85b2b7b8 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -11,17 +11,15 @@ // Example from lkuper's intern talk, August 2012. -use std::gc::{GC, Gc}; - trait Equal { - fn isEq(&self, a: Self) -> bool; + fn isEq(&self, a: &Self) -> bool; } enum Color { cyan, magenta, yellow, black } impl Equal for Color { - fn isEq(&self, a: Color) -> bool { - match (*self, a) { + fn isEq(&self, a: &Color) -> bool { + match (*self, *a) { (cyan, cyan) => { true } (magenta, magenta) => { true } (yellow, yellow) => { true } @@ -33,15 +31,15 @@ impl Equal for Color { enum ColorTree { leaf(Color), - branch(Gc, Gc) + branch(Box, Box) } impl Equal for ColorTree { - fn isEq(&self, a: ColorTree) -> bool { - match (*self, a) { - (leaf(x), leaf(y)) => { x.isEq(y) } - (branch(l1, r1), branch(l2, r2)) => { - (*l1).isEq(*l2) && (*r1).isEq(*r2) + fn isEq(&self, a: &ColorTree) -> bool { + match (self, a) { + (&leaf(x), &leaf(y)) => { x.isEq(&y) } + (&branch(ref l1, ref r1), &branch(ref l2, ref r2)) => { + (&**l1).isEq(&**l2) && (&**r1).isEq(&**r2) } _ => { false } } @@ -49,19 +47,19 @@ impl Equal for ColorTree { } pub fn main() { - assert!(cyan.isEq(cyan)); - assert!(magenta.isEq(magenta)); - assert!(!cyan.isEq(yellow)); - assert!(!magenta.isEq(cyan)); + assert!(cyan.isEq(&cyan)); + assert!(magenta.isEq(&magenta)); + assert!(!cyan.isEq(&yellow)); + assert!(!magenta.isEq(&cyan)); - assert!(leaf(cyan).isEq(leaf(cyan))); - assert!(!leaf(cyan).isEq(leaf(yellow))); + assert!(leaf(cyan).isEq(&leaf(cyan))); + assert!(!leaf(cyan).isEq(&leaf(yellow))); - assert!(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)) - .isEq(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)))); + assert!(branch(box leaf(magenta), box leaf(cyan)) + .isEq(&branch(box leaf(magenta), box leaf(cyan)))); - assert!(!branch(box(GC) leaf(magenta), box(GC) leaf(cyan)) - .isEq(branch(box(GC) leaf(magenta), box(GC) leaf(magenta)))); + assert!(!branch(box leaf(magenta), box leaf(cyan)) + .isEq(&branch(box leaf(magenta), box leaf(magenta)))); println!("Assertions all succeeded!"); } diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs deleted file mode 100644 index e342dcb365d..00000000000 --- a/src/test/run-pass/uniq-cc-generic.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-pretty FIXME(#14193) - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum maybe_pointy { - none, - p(Gc>), -} - -struct Pointy { - a : maybe_pointy, - d : proc():Send -> uint, -} - -fn make_uniq_closure(a: A) -> proc():Send -> uint { - proc() { &a as *const A as uint } -} - -fn empty_pointy() -> Gc> { - return box(GC) RefCell::new(Pointy { - a : none, - d : make_uniq_closure("hi".to_string()) - }) -} - -pub fn main() { - let v = empty_pointy(); - { - let mut vb = v.borrow_mut(); - vb.a = p(v); - } -} diff --git a/src/test/run-pass/uniq-cc.rs b/src/test/run-pass/uniq-cc.rs deleted file mode 100644 index c7aca64c7cb..00000000000 --- a/src/test/run-pass/uniq-cc.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum maybe_pointy { - none, - p(Gc>), -} - -struct Pointy { - a : maybe_pointy, - c : Box, - d : proc():Send->(), -} - -fn empty_pointy() -> Gc> { - return box(GC) RefCell::new(Pointy { - a : none, - c : box 22, - d : proc() {}, - }) -} - -pub fn main() { - let v = empty_pointy(); - { - let mut vb = v.borrow_mut(); - vb.a = p(v); - } -} diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index 478565c86fd..493ec8ddc20 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - fn f(t: T) -> T { let t1 = t; t1 @@ -19,6 +17,4 @@ fn f(t: T) -> T { pub fn main() { let t = f(box 100i); assert_eq!(t, box 100i); - let t = f(box box(GC) vec!(100i)); - assert_eq!(t, box box(GC) vec!(100i)); } diff --git a/src/test/run-pass/unwind-box.rs b/src/test/run-pass/unwind-box.rs deleted file mode 100644 index 70c8c5b64e4..00000000000 --- a/src/test/run-pass/unwind-box.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::task; -use std::gc::GC; - -fn f() { - let _a = box(GC) 0i; - fail!(); -} - -pub fn main() { - task::spawn(f); -} diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs deleted file mode 100644 index 6d04c0e26ad..00000000000 --- a/src/test/run-pass/unwind-resource2.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unsafe_destructor)] - -use std::task; -use std::gc::{Gc, GC}; - -struct complainer { - c: Gc, -} - -#[unsafe_destructor] -impl Drop for complainer { - fn drop(&mut self) {} -} - -fn complainer(c: Gc) -> complainer { - complainer { - c: c - } -} - -fn f() { - let _c = complainer(box(GC) 0); - fail!(); -} - -pub fn main() { - task::spawn(f); -} diff --git a/src/test/run-pass/vec-drop.rs b/src/test/run-pass/vec-drop.rs deleted file mode 100644 index 6cc95a2e548..00000000000 --- a/src/test/run-pass/vec-drop.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -struct Pair { x: int, y: int } - -pub fn main() { - // This just tests whether the vec leaks its members. - - let _pvec: Vec> = - vec!(box(GC) Pair{x: 1, y: 2}, - box(GC) Pair{x: 3, y: 4}, - box(GC) Pair{x: 5, y: 6}); -} diff --git a/src/test/run-pass/vec-slice-drop.rs b/src/test/run-pass/vec-slice-drop.rs index 42132f0a12f..498ec0e8fba 100644 --- a/src/test/run-pass/vec-slice-drop.rs +++ b/src/test/run-pass/vec-slice-drop.rs @@ -11,28 +11,27 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // Make sure that destructors get run on slice literals -struct foo { - x: Gc>, +struct foo<'a> { + x: &'a Cell, } #[unsafe_destructor] -impl Drop for foo { +impl<'a> Drop for foo<'a> { fn drop(&mut self) { self.x.set(self.x.get() + 1); } } -fn foo(x: Gc>) -> foo { +fn foo(x: &Cell) -> foo { foo { x: x } } pub fn main() { - let x = box(GC) Cell::new(0); + let x = &Cell::new(0); { let l = &[foo(x)]; assert_eq!(l[0].x.get(), 0); diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index e8489e7c386..72204c28f82 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -11,7 +11,6 @@ use std::cell::Cell; use std::mem::swap; -use std::gc::{Gc, GC}; // Just a grab bag of stuff that you wouldn't want to actually write. @@ -23,10 +22,10 @@ fn funny() { } fn what() { - fn the(x: Gc>) { + fn the(x: &Cell) { return while !x.get() { x.set(true); }; } - let i = box(GC) Cell::new(false); + let i = &Cell::new(false); let dont = {||the(i)}; dont(); assert!((i.get())); From 4184396f28d5612520f7b30718df9fff6918d239 Mon Sep 17 00:00:00 2001 From: Dan Schatzberg Date: Thu, 4 Sep 2014 15:25:23 -0400 Subject: [PATCH 30/43] Add lifetime bounds on Items and MutItems. This also requires a fix for Vec's MoveItems. This resolves issue #16941 --- src/libcollections/vec.rs | 56 +++++++++++++++++++++++++++++---------- src/libcore/slice.rs | 4 +-- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 9dc122cfc7d..6fdf2fce0a2 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -845,11 +845,12 @@ impl Vec { #[inline] pub fn into_iter(self) -> MoveItems { unsafe { - let iter = mem::transmute(self.as_slice().iter()); let ptr = self.ptr; let cap = self.cap; + let begin = self.ptr as *const T; + let end = (self.ptr as uint + self.len()) as *const T; mem::forget(self); - MoveItems { allocation: ptr, cap: cap, iter: iter } + MoveItems { allocation: ptr, cap: cap, ptr: begin, end: end } } } @@ -1773,7 +1774,8 @@ impl MutableSeq for Vec { pub struct MoveItems { allocation: *mut T, // the block of memory allocated for the vector cap: uint, // the capacity of the vector - iter: Items<'static, T> + ptr: *const T, + end: *const T } impl MoveItems { @@ -1793,17 +1795,33 @@ impl Iterator for MoveItems { #[inline] fn next<'a>(&'a mut self) -> Option { unsafe { - // Unsafely transmute from Items<'static, T> to Items<'a, - // T> because otherwise the type checker requires that T - // be bounded by 'static. - let iter: &mut Items<'a, T> = mem::transmute(&mut self.iter); - iter.next().map(|x| ptr::read(x)) + if self.ptr == self.end { + None + } else { + if mem::size_of::() == 0 { + // purposefully don't use 'ptr.offset' because for + // vectors with 0-size elements this would return the + // same pointer. + self.ptr = mem::transmute(self.ptr as uint + 1); + + // Use a non-null pointer value + Some(ptr::read(mem::transmute(1u))) + } else { + let old = self.ptr; + self.ptr = self.ptr.offset(1); + + Some(ptr::read(old)) + } + } } } #[inline] fn size_hint(&self) -> (uint, Option) { - self.iter.size_hint() + let diff = (self.end as uint) - (self.ptr as uint); + let size = mem::size_of::(); + let exact = diff / (if size == 0 {1} else {size}); + (exact, Some(exact)) } } @@ -1811,11 +1829,21 @@ impl DoubleEndedIterator for MoveItems { #[inline] fn next_back<'a>(&'a mut self) -> Option { unsafe { - // Unsafely transmute from Items<'static, T> to Items<'a, - // T> because otherwise the type checker requires that T - // be bounded by 'static. - let iter: &mut Items<'a, T> = mem::transmute(&mut self.iter); - iter.next_back().map(|x| ptr::read(x)) + if self.end == self.ptr { + None + } else { + if mem::size_of::() == 0 { + // See above for why 'ptr.offset' isn't used + self.end = mem::transmute(self.end as uint - 1); + + // Use a non-null pointer value + Some(ptr::read(mem::transmute(1u))) + } else { + self.end = self.end.offset(-1); + + Some(ptr::read(mem::transmute(self.end))) + } + } } } } diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index a8becb315b2..6a8bea001bf 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1163,7 +1163,7 @@ macro_rules! iterator { /// Immutable slice iterator #[experimental = "needs review"] -pub struct Items<'a, T> { +pub struct Items<'a, T: 'a> { ptr: *const T, end: *const T, marker: marker::ContravariantLifetime<'a> @@ -1206,7 +1206,7 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { /// Mutable slice iterator. #[experimental = "needs review"] -pub struct MutItems<'a, T> { +pub struct MutItems<'a, T: 'a> { ptr: *mut T, end: *mut T, marker: marker::ContravariantLifetime<'a>, From f14cb96b07517b5638bf966e6f6e30b946552912 Mon Sep 17 00:00:00 2001 From: Dan Schatzberg Date: Thu, 4 Sep 2014 17:59:28 -0400 Subject: [PATCH 31/43] Use RawPtr::offset when size_of::() > 0 --- src/libcollections/vec.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 6fdf2fce0a2..b3a3609bdce 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -848,7 +848,11 @@ impl Vec { let ptr = self.ptr; let cap = self.cap; let begin = self.ptr as *const T; - let end = (self.ptr as uint + self.len()) as *const T; + let end = if mem::size_of::() == 0 { + (ptr as uint + self.len()) as *const T; + } else { + ptr.offset(self.len() as int) + }; mem::forget(self); MoveItems { allocation: ptr, cap: cap, ptr: begin, end: end } } From 0c63a4a4f58fe8f7e989fa431af860ce00ea0980 Mon Sep 17 00:00:00 2001 From: Dan Schatzberg Date: Thu, 2 Oct 2014 11:19:47 -0400 Subject: [PATCH 32/43] Add tests for MoveItems --- src/libcollections/vec.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index b3a3609bdce..9c3842dfd9c 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -2565,6 +2565,39 @@ mod tests { assert_eq!(v.map_in_place(|_| ZeroSized).as_slice(), [ZeroSized, ZeroSized].as_slice()); } + #[test] + fn test_move_items() { + let mut vec = vec!(1i, 2, 3); + let mut vec2 : Vec = vec!(); + for i in vec.move_iter() { + vec2.push(i); + } + assert!(vec2 == vec!(1i, 2, 3)); + assert!(vec.empty()); + } + + #[test] + fn test_move_items_reverse() { + let mut vec = vec!(1i, 2, 3); + let mut vec2 : Vec = vec!(); + for i in vec.move_iter().rev() { + vec2.push(i); + } + assert!(vec2 == vec!(3i, 2, 1)); + assert!(vec.empty()); + } + + #[test] + fn test_move_items_zero_sized() { + let mut vec = vec!((), (), ()); + let mut vec2 : Vec<()> = vec!(); + for i in vec.move_iter() { + vec2.push(i); + } + assert!(vec2 == vec!((), (), ())); + assert!(vec.empty()); + } + #[bench] fn bench_new(b: &mut Bencher) { b.iter(|| { From 49e593c3d6494e210c215b4d353270616450980f Mon Sep 17 00:00:00 2001 From: Dan Schatzberg Date: Thu, 2 Oct 2014 14:06:31 -0400 Subject: [PATCH 33/43] Add fixes for new lifetime bounds --- src/libcollections/btree/map.rs | 4 ++-- src/libcollections/vec.rs | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index b0ba2254621..ab160595433 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -46,12 +46,12 @@ struct AbsEntries { } /// An iterator over a BTreeMap's entries. -pub struct Entries<'a, K, V> { +pub struct Entries<'a, K: 'a, V: 'a> { inner: AbsEntries> } /// A mutable iterator over a BTreeMap's entries. -pub struct MutEntries<'a, K, V> { +pub struct MutEntries<'a, K: 'a, V: 'a> { inner: AbsEntries> } diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 9c3842dfd9c..9ada9ede435 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -849,9 +849,9 @@ impl Vec { let cap = self.cap; let begin = self.ptr as *const T; let end = if mem::size_of::() == 0 { - (ptr as uint + self.len()) as *const T; + (ptr as uint + self.len()) as *const T } else { - ptr.offset(self.len() as int) + ptr.offset(self.len() as int) as *const T }; mem::forget(self); MoveItems { allocation: ptr, cap: cap, ptr: begin, end: end } @@ -1788,7 +1788,7 @@ impl MoveItems { pub fn unwrap(mut self) -> Vec { unsafe { for _x in self { } - let MoveItems { allocation, cap, iter: _iter } = self; + let MoveItems { allocation, cap, ptr: _ptr, end: _end } = self; mem::forget(self); Vec { ptr: allocation, cap: cap, len: 0 } } @@ -2569,33 +2569,30 @@ mod tests { fn test_move_items() { let mut vec = vec!(1i, 2, 3); let mut vec2 : Vec = vec!(); - for i in vec.move_iter() { + for i in vec.into_iter() { vec2.push(i); } assert!(vec2 == vec!(1i, 2, 3)); - assert!(vec.empty()); } #[test] fn test_move_items_reverse() { let mut vec = vec!(1i, 2, 3); let mut vec2 : Vec = vec!(); - for i in vec.move_iter().rev() { + for i in vec.into_iter().rev() { vec2.push(i); } assert!(vec2 == vec!(3i, 2, 1)); - assert!(vec.empty()); } #[test] fn test_move_items_zero_sized() { let mut vec = vec!((), (), ()); let mut vec2 : Vec<()> = vec!(); - for i in vec.move_iter() { + for i in vec.into_iter() { vec2.push(i); } assert!(vec2 == vec!((), (), ())); - assert!(vec.empty()); } #[bench] From 16cca6dbada93a7468825e0eb106ea05a7417c01 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 2 Oct 2014 15:01:25 -0400 Subject: [PATCH 34/43] I am bad at math --- src/doc/guide-lifetimes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/guide-lifetimes.md b/src/doc/guide-lifetimes.md index 545d286c5d7..dd79d63d514 100644 --- a/src/doc/guide-lifetimes.md +++ b/src/doc/guide-lifetimes.md @@ -307,7 +307,7 @@ copying. # } fn compute_area(shape: &Shape) -> f64 { match *shape { - Circle(_, radius) => 2.0 * std::f64::consts::PI * radius * radius, + Circle(_, radius) => std::f64::consts::PI * radius * radius, Rectangle(_, ref size) => size.w * size.h } } From 85a8b92b5143307d7e2f625930eb7d179d2c1213 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 2 Oct 2014 15:12:27 -0400 Subject: [PATCH 35/43] extra comment about macros Fixes #17190 --- src/doc/guide.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/doc/guide.md b/src/doc/guide.md index 074dfc17b0d..fa0cbb547e0 100644 --- a/src/doc/guide.md +++ b/src/doc/guide.md @@ -195,9 +195,11 @@ The second point is the `println!()` part. This is calling a Rust **macro**, which is how metaprogramming is done in Rust. If it were a function instead, it would look like this: `println()`. For our purposes, we don't need to worry about this difference. Just know that sometimes, you'll see a `!`, and that -means that you're calling a macro instead of a normal function. One last thing -to mention: Rust's macros are significantly different than C macros, if you've -used those. Don't be scared of using macros. We'll get to the details +means that you're calling a macro instead of a normal function. Rust implements +`println!` as a macro rather than a function for good reasons, but that's a +very advanced topic. You'll learn more when we talk about macros later. One +last thing to mention: Rust's macros are significantly different than C macros, +if you've used those. Don't be scared of using macros. We'll get to the details eventually, you'll just have to trust us for now. Next, `"Hello, world!"` is a **string**. Strings are a surprisingly complicated From 8d7274b31efe248322f9b0d6a3082a92317f1dfa Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 2 Oct 2014 03:29:39 -0400 Subject: [PATCH 36/43] alloc: fix reallocate_inplace implementation The returned size is the new real size of the allocation. --- src/liballoc/heap.rs | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 0d2872bcba0..72384e25c3b 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -182,9 +182,15 @@ mod imp { #[inline] pub unsafe fn reallocate_inplace(ptr: *mut u8, size: uint, align: uint, - _old_size: uint) -> bool { + old_size: uint) -> bool { let flags = align_to_flags(align); - je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) == size as size_t + let new_size = je_xallocx(ptr as *mut c_void, size as size_t, 0, flags) as uint; + // checking for failure to shrink is tricky + if size < old_size { + usable_size(size, align) == new_size as uint + } else { + new_size >= size + } } #[inline] @@ -250,9 +256,9 @@ mod imp { } #[inline] - pub unsafe fn reallocate_inplace(_ptr: *mut u8, _size: uint, _align: uint, - _old_size: uint) -> bool { - false + pub unsafe fn reallocate_inplace(_ptr: *mut u8, size: uint, _align: uint, + old_size: uint) -> bool { + size == old_size } #[inline] @@ -312,9 +318,9 @@ mod imp { } #[inline] - pub unsafe fn reallocate_inplace(_ptr: *mut u8, _size: uint, _align: uint, - _old_size: uint) -> bool { - false + pub unsafe fn reallocate_inplace(_ptr: *mut u8, size: uint, _align: uint, + old_size: uint) -> bool { + size == old_size } #[inline] @@ -335,10 +341,21 @@ mod imp { } #[cfg(test)] -mod bench { +mod test { extern crate test; use self::test::Bencher; + #[test] + fn basic_reallocate_inplace_noop() { + unsafe { + let size = 4000; + let ptr = heap::allocate(size, 8); + let ret = heap::reallocate_inplace(ptr, size, 8, size); + heap::deallocate(ptr, size, 8); + assert!(ret); + } + } + #[bench] fn alloc_owned_small(b: &mut Bencher) { b.iter(|| { From af633ce157082bf2b0fd0577765e9b49c34c3e90 Mon Sep 17 00:00:00 2001 From: Benjamin Herr Date: Thu, 2 Oct 2014 20:55:26 +0200 Subject: [PATCH 37/43] native: fix passing errno to parent after fork The bitshifts were wrong in that they invoked undefined behavior and only passed the lower byte of the presumed-to-be-32bit errno value. Apparently all actually possible values for errno happen to be easily under 256, so this didn't cause any actual problems. This commit fixes the bitshifts, but doesn't generalize to errno types that aren't 32bit. --- src/libnative/io/process.rs | 17 ++-- src/test/run-pass/unix-process-spawn-errno.rs | 94 +++++++++++++++++++ 2 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 src/test/run-pass/unix-process-spawn-errno.rs diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index 3a6ae42f946..7a0c1c35d65 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -583,10 +583,11 @@ fn spawn_process_os(cfg: ProcessConfig, let mut bytes = [0, ..4]; return match input.inner_read(bytes) { Ok(4) => { - let errno = (bytes[0] << 24) as i32 | - (bytes[1] << 16) as i32 | - (bytes[2] << 8) as i32 | - (bytes[3] << 0) as i32; + let errno = (bytes[0] as i32 << 24) | + (bytes[1] as i32 << 16) | + (bytes[2] as i32 << 8) | + (bytes[3] as i32 << 0); + Err(IoError { code: errno as uint, detail: None, @@ -637,10 +638,10 @@ fn spawn_process_os(cfg: ProcessConfig, fn fail(output: &mut file::FileDesc) -> ! { let errno = os::errno(); let bytes = [ - (errno << 24) as u8, - (errno << 16) as u8, - (errno << 8) as u8, - (errno << 0) as u8, + (errno >> 24) as u8, + (errno >> 16) as u8, + (errno >> 8) as u8, + (errno >> 0) as u8, ]; assert!(output.inner_write(bytes).is_ok()); unsafe { libc::_exit(1) } diff --git a/src/test/run-pass/unix-process-spawn-errno.rs b/src/test/run-pass/unix-process-spawn-errno.rs new file mode 100644 index 00000000000..555bf2cd4c0 --- /dev/null +++ b/src/test/run-pass/unix-process-spawn-errno.rs @@ -0,0 +1,94 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-windows + +#![feature(macro_rules)] + +extern crate native; +extern crate rustrt; +extern crate libc; +use libc::{c_char, c_int}; +use native::io::process; +use rustrt::rtio; +use rustrt::c_str; + +macro_rules! c_string { + ($s:expr) => { { + let ptr = concat!($s, "\0").as_ptr() as *const i8; + unsafe { &c_str::CString::new(ptr, false) } + } } +} + +static EXPECTED_ERRNO: c_int = 0x778899aa; + +#[no_mangle] +pub unsafe extern "C" fn chdir(_: *const c_char) -> c_int { + // copied from std::os::errno() + #[cfg(any(target_os = "macos", + target_os = "ios", + target_os = "freebsd"))] + fn errno_location() -> *mut c_int { + extern { + fn __error() -> *mut c_int; + } + unsafe { + __error() + } + } + + #[cfg(target_os = "dragonfly")] + fn errno_location() -> *mut c_int { + extern { + fn __dfly_error() -> *mut c_int; + } + unsafe { + __dfly_error() + } + } + + #[cfg(any(target_os = "linux", target_os = "android"))] + fn errno_location() -> *mut c_int { + extern { + fn __errno_location() -> *mut c_int; + } + unsafe { + __errno_location() + } + } + + *errno_location() = EXPECTED_ERRNO; + return -1; +} + +fn main() { + let program = c_string!("true"); + let cwd = c_string!("whatever"); + let cfg = rtio::ProcessConfig { + program: program, + args: &[], + env: None, + cwd: Some(cwd), + stdin: rtio::Ignored, + stdout: rtio::Ignored, + stderr: rtio::Ignored, + extra_io: &[], + uid: None, + gid: None, + detach: false + }; + + match process::Process::spawn(cfg) { + Ok(_) => { fail!("spawn() should have failled"); } + Err(rtio::IoError { code: err, ..}) => { + assert_eq!(err as c_int, EXPECTED_ERRNO); + } + }; +} From f2973f63a3db6e497c6f5a912c621fedd9a5fac8 Mon Sep 17 00:00:00 2001 From: Jakub Wieczorek Date: Wed, 1 Oct 2014 23:28:54 +0200 Subject: [PATCH 38/43] Fix cross-crate tuple structs in statics Fixes #17169. Fixes #17649. --- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_match.rs | 2 +- src/librustc/middle/mem_categorization.rs | 1 - src/librustc/middle/privacy.rs | 9 --------- src/librustc/middle/resolve.rs | 5 +++++ src/librustc/middle/trans/_match.rs | 2 -- src/test/auxiliary/xcrate_unit_struct.rs | 2 ++ src/test/run-pass/xcrate-unit-struct.rs | 4 ++++ 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index cc3679ec31d..d8753c0b12a 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -149,7 +149,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) { } ExprCall(ref callee, _) => { match v.tcx.def_map.borrow().find(&callee.id) { - Some(&DefStruct(..)) => {} // OK. + Some(&DefStruct(..)) | Some(&DefVariant(..)) => {} // OK. _ => { span_err!(v.tcx.sess, e.span, E0015, diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index de9125ec449..36aa61c5c54 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -757,7 +757,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], DefStatic(..) => cx.tcx.sess.span_bug(pat_span, "static pattern should've been rewritten"), DefVariant(_, id, _) if *constructor != Variant(id) => None, - DefVariant(..) | DefFn(..) | DefStruct(..) => { + DefVariant(..) | DefStruct(..) => { Some(match args { &Some(ref args) => args.iter().map(|p| &**p).collect(), &None => Vec::from_elem(arity, &DUMMY_WILD_PAT) diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index bb44b1f55cb..c829b6dab44 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -1083,7 +1083,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { if_ok!(self.cat_pattern(subcmt, &**subpat, |x,y,z| op(x,y,z))); } } - Some(&def::DefFn(..)) | Some(&def::DefStruct(..)) => { for (i, subpat) in subpats.iter().enumerate() { let subpat_ty = if_ok!(self.pat_ty(&**subpat)); // see (*2) diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 22ac390602d..7e415d1f5c1 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -931,15 +931,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> { maybe_did.unwrap_or(did) }) } - // Tuple struct constructors across crates are identified as - // DefFn types, so we explicitly handle that case here. - Some(&def::DefFn(did, _, _)) if !is_local(did) => { - match csearch::get_tuple_struct_definition_if_ctor( - &self.tcx.sess.cstore, did) { - Some(did) => guard(did), - None => {} - } - } _ => {} } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 42a98be0fb8..cb93ad1b5cf 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1824,6 +1824,11 @@ impl<'a> Resolver<'a> { child_name_bindings.define_value(def, DUMMY_SP, is_exported); } } + DefFn(ctor_id, _, true) => { + child_name_bindings.define_value( + csearch::get_tuple_struct_definition_if_ctor(&self.session.cstore, ctor_id) + .map_or(def, |_| DefStruct(ctor_id)), DUMMY_SP, is_public); + } DefFn(..) | DefStaticMethod(..) | DefStatic(..) => { debug!("(building reduced graph for external \ crate) building value (fn/static) {}", final_ident); diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 68d0bb2d8b4..ca62f518619 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -698,7 +698,6 @@ fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: uint) -> bool { } ast::PatEnum(..) | ast::PatIdent(_, _, None) => { match tcx.def_map.borrow().find(&pat.id) { - Some(&def::DefFn(..)) | Some(&def::DefStruct(..)) => true, _ => false } @@ -1646,7 +1645,6 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } } - Some(def::DefFn(..)) | Some(def::DefStruct(..)) => { match *sub_pats { None => { diff --git a/src/test/auxiliary/xcrate_unit_struct.rs b/src/test/auxiliary/xcrate_unit_struct.rs index 6487c704765..d56d7a70edf 100644 --- a/src/test/auxiliary/xcrate_unit_struct.rs +++ b/src/test/auxiliary/xcrate_unit_struct.rs @@ -19,6 +19,8 @@ pub enum Unit { Argument(Struct) } +pub struct TupleStruct(pub uint, pub &'static str); + // used by the cfail test pub struct StructWithFields { diff --git a/src/test/run-pass/xcrate-unit-struct.rs b/src/test/run-pass/xcrate-unit-struct.rs index 9ba4b707268..f66caa5fbfc 100644 --- a/src/test/run-pass/xcrate-unit-struct.rs +++ b/src/test/run-pass/xcrate-unit-struct.rs @@ -16,17 +16,21 @@ static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::UnitVariant; static s3: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(xcrate_unit_struct::Struct); static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(s1); +static s5: xcrate_unit_struct::TupleStruct = xcrate_unit_struct::TupleStruct(20, "foo"); fn f1(_: xcrate_unit_struct::Struct) {} fn f2(_: xcrate_unit_struct::Unit) {} +fn f3(_: xcrate_unit_struct::TupleStruct) {} pub fn main() { f1(xcrate_unit_struct::Struct); f2(xcrate_unit_struct::UnitVariant); f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct)); + f3(xcrate_unit_struct::TupleStruct(10, "bar")); f1(s1); f2(s2); f2(s3); f2(s4); + f3(s5); } From 53cdaa58d30216c1f8f2536ab8cb307e3cec8611 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 2 Oct 2014 13:14:14 -0700 Subject: [PATCH 39/43] std: Help diagnose a flaky test This test has recently been failing on the bots, and I'm not entirely sure why. I haven't been able to reproduce locally or on the bots, so I'm adding some messages to help diagnose the problem hopefully. --- src/libstd/io/process.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 5220e5c984a..d8be92e4514 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -958,7 +958,9 @@ mod tests { // don't check windows magical empty-named variables assert!(k.is_empty() || output.as_slice() - .contains(format!("{}={}", *k, *v).as_slice())); + .contains(format!("{}={}", *k, *v).as_slice()), + "output doesn't contain `{}={}`\n{}", + k, v, output); } } #[cfg(target_os="android")] From 52d2f2a938c793bb20964156a2657271fa7f91ab Mon Sep 17 00:00:00 2001 From: Jakub Wieczorek Date: Thu, 2 Oct 2014 21:52:06 +0200 Subject: [PATCH 40/43] Add tests for a few resolved issues --- src/test/compile-fail/issue-13497-2.rs | 17 ++++++++ src/test/compile-fail/issue-13497.rs | 18 ++++++++ src/test/compile-fail/issue-14366.rs | 17 ++++++++ src/test/compile-fail/issue-14853.rs | 30 +++++++++++++ src/test/run-pass/issue-11869.rs | 23 ++++++++++ src/test/run-pass/issue-13167.rs | 27 ++++++++++++ src/test/run-pass/issue-13405.rs | 25 +++++++++++ src/test/run-pass/issue-13434.rs | 31 ++++++++++++++ src/test/run-pass/issue-13703.rs | 13 ++++++ src/test/run-pass/issue-14919.rs | 58 ++++++++++++++++++++++++++ src/test/run-pass/issue-15673.rs | 15 +++++++ src/test/run-pass/issue-15924.rs | 32 ++++++++++++++ src/test/run-pass/issue-5718.rs | 33 +++++++++++++++ 13 files changed, 339 insertions(+) create mode 100644 src/test/compile-fail/issue-13497-2.rs create mode 100644 src/test/compile-fail/issue-13497.rs create mode 100644 src/test/compile-fail/issue-14366.rs create mode 100644 src/test/compile-fail/issue-14853.rs create mode 100644 src/test/run-pass/issue-11869.rs create mode 100644 src/test/run-pass/issue-13167.rs create mode 100644 src/test/run-pass/issue-13405.rs create mode 100644 src/test/run-pass/issue-13434.rs create mode 100644 src/test/run-pass/issue-13703.rs create mode 100644 src/test/run-pass/issue-14919.rs create mode 100644 src/test/run-pass/issue-15673.rs create mode 100644 src/test/run-pass/issue-15924.rs create mode 100644 src/test/run-pass/issue-5718.rs diff --git a/src/test/compile-fail/issue-13497-2.rs b/src/test/compile-fail/issue-13497-2.rs new file mode 100644 index 00000000000..c7a8c87bb23 --- /dev/null +++ b/src/test/compile-fail/issue-13497-2.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn read_lines_borrowed<'a>() -> Vec<&'a str> { + let rawLines: Vec = vec!["foo ".to_string(), " bar".to_string()]; + rawLines //~ ERROR `rawLines` does not live long enough + .iter().map(|l| l.as_slice().trim()).collect() +} + +fn main() {} diff --git a/src/test/compile-fail/issue-13497.rs b/src/test/compile-fail/issue-13497.rs new file mode 100644 index 00000000000..da8b93e3c93 --- /dev/null +++ b/src/test/compile-fail/issue-13497.rs @@ -0,0 +1,18 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn read_lines_borrowed1() -> Vec< + &str //~ ERROR missing lifetime specifier +> { + let rawLines: Vec = vec!["foo ".to_string(), " bar".to_string()]; + rawLines.iter().map(|l| l.as_slice().trim()).collect() +} + +fn main() {} diff --git a/src/test/compile-fail/issue-14366.rs b/src/test/compile-fail/issue-14366.rs new file mode 100644 index 00000000000..ceb6daac65e --- /dev/null +++ b/src/test/compile-fail/issue-14366.rs @@ -0,0 +1,17 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + let _x = "test" as &::std::any::Any; +//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str` +//~^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type +//~^^^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str` +//~^^^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type +} diff --git a/src/test/compile-fail/issue-14853.rs b/src/test/compile-fail/issue-14853.rs new file mode 100644 index 00000000000..4243b98e0dd --- /dev/null +++ b/src/test/compile-fail/issue-14853.rs @@ -0,0 +1,30 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt::Show; + +trait Something { + fn yay(_: Option, thing: &[T]) -> String { + } +} + +struct X { data: u32 } + +impl Something for X { + fn yay(_:Option, thing: &[T]) -> String { +//~^ ERROR in method `yay`, type parameter 0 requires bound `core::str::Str`, which is not required + format!("{:s}", thing[0]) + } +} + +fn main() { + let arr = &["one", "two", "three"]; + println!("{}", Something::yay(None::, arr)); +} diff --git a/src/test/run-pass/issue-11869.rs b/src/test/run-pass/issue-11869.rs new file mode 100644 index 00000000000..c75d02c6328 --- /dev/null +++ b/src/test/run-pass/issue-11869.rs @@ -0,0 +1,23 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct A { + a: String +} + +fn borrow<'a>(binding: &'a A) -> &'a str { + match binding.a.as_slice() { + "in" => "in_", + "ref" => "ref_", + ident => ident + } +} + +fn main() {} diff --git a/src/test/run-pass/issue-13167.rs b/src/test/run-pass/issue-13167.rs new file mode 100644 index 00000000000..1a58a6842d4 --- /dev/null +++ b/src/test/run-pass/issue-13167.rs @@ -0,0 +1,27 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::slice; + +pub struct PhfMapEntries<'a, T> { + iter: slice::Items<'a, (&'static str, T)>, +} + +impl<'a, T> Iterator<(&'static str, &'a T)> for PhfMapEntries<'a, T> { + fn next(&mut self) -> Option<(&'static str, &'a T)> { + self.iter.by_ref().map(|&(key, ref value)| (key, value)).next() + } + + fn size_hint(&self) -> (uint, Option) { + self.iter.size_hint() + } +} + +fn main() {} diff --git a/src/test/run-pass/issue-13405.rs b/src/test/run-pass/issue-13405.rs new file mode 100644 index 00000000000..05943943d95 --- /dev/null +++ b/src/test/run-pass/issue-13405.rs @@ -0,0 +1,25 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo<'a> { + i: &'a bool, + j: Option<&'a int>, +} + +impl<'a> Foo<'a> { + fn bar(&mut self, j: &int) { + let child = Foo { + i: self.i, + j: Some(j) + }; + } +} + +fn main() {} diff --git a/src/test/run-pass/issue-13434.rs b/src/test/run-pass/issue-13434.rs new file mode 100644 index 00000000000..25b53bb3a53 --- /dev/null +++ b/src/test/run-pass/issue-13434.rs @@ -0,0 +1,31 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate debug; + +struct MyStruct; + +trait Repro { + fn repro(self, s: MyStruct) -> String; +} + +impl Repro for |MyStruct|:'static -> String { + fn repro(self, s: MyStruct) -> String { + self(s) + } +} + +fn do_stuff(r: R) -> String { + r.repro(MyStruct) +} + +pub fn main() { + assert_eq!("MyStruct".to_string(), do_stuff(|s: MyStruct| format!("{:?}", s))); +} diff --git a/src/test/run-pass/issue-13703.rs b/src/test/run-pass/issue-13703.rs new file mode 100644 index 00000000000..c9c78f6408b --- /dev/null +++ b/src/test/run-pass/issue-13703.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct Foo<'a, 'b: 'a> { foo: &'a &'b int } +pub fn foo<'a, 'b>(x: Foo<'a, 'b>, _o: Option<& & ()>) { let _y = x.foo; } +fn main() {} diff --git a/src/test/run-pass/issue-14919.rs b/src/test/run-pass/issue-14919.rs new file mode 100644 index 00000000000..db29eb314bd --- /dev/null +++ b/src/test/run-pass/issue-14919.rs @@ -0,0 +1,58 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +trait Matcher { + fn next_match(&mut self) -> Option<(uint, uint)>; +} + +struct CharPredMatcher<'a, 'b> { + str: &'a str, + pred: |char|:'b -> bool +} + +impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> { + fn next_match(&mut self) -> Option<(uint, uint)> { + None + } +} + +trait IntoMatcher<'a, T> { + fn into_matcher(self, &'a str) -> T; +} + +impl<'a, 'b> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for |char|:'b -> bool { + fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> { + CharPredMatcher { + str: s, + pred: self + } + } +} + +struct MatchIndices { + matcher: M +} + +impl Iterator<(uint, uint)> for MatchIndices { + fn next(&mut self) -> Option<(uint, uint)> { + self.matcher.next_match() + } +} + +fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndices { + let string_matcher = from.into_matcher(s); + MatchIndices { matcher: string_matcher } +} + +fn main() { + let s = "abcbdef"; + match_indices(s, |c: char| c == 'b') + .collect::>(); +} diff --git a/src/test/run-pass/issue-15673.rs b/src/test/run-pass/issue-15673.rs new file mode 100644 index 00000000000..051d98aa1d8 --- /dev/null +++ b/src/test/run-pass/issue-15673.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::iter::AdditiveIterator; +fn main() { + let x: [u64, ..3] = [1, 2, 3]; + assert_eq!(6, range(0, 3).map(|i| x[i]).sum()); +} diff --git a/src/test/run-pass/issue-15924.rs b/src/test/run-pass/issue-15924.rs new file mode 100644 index 00000000000..8d5b928964d --- /dev/null +++ b/src/test/run-pass/issue-15924.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unsafe_destructor)] + +extern crate serialize; + +use std::io::IoError; +use serialize::{Encoder, Encodable}; +use serialize::json; + +struct Foo { + v: T, +} + +#[unsafe_destructor] +impl<'a, T: Encodable, IoError>> Drop for Foo { + fn drop(&mut self) { + json::encode(&self.v); + } +} + +fn main() { + let _ = Foo { v: 10i }; +} diff --git a/src/test/run-pass/issue-5718.rs b/src/test/run-pass/issue-5718.rs new file mode 100644 index 00000000000..f2167da31fc --- /dev/null +++ b/src/test/run-pass/issue-5718.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(macro_rules)] + +struct Element; + +macro_rules! foo { + ($tag: expr, $string: expr) => { + if $tag == $string { + let element = box Element; + unsafe { + return std::mem::transmute::<_, uint>(element); + } + } + } +} + +fn bar() -> uint { + foo!("a", "b"); + 0 +} + +fn main() { + bar(); +} From cc9347a90293d5bfead754cb91c828fb6555b3ff Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 2 Oct 2014 13:50:43 -0700 Subject: [PATCH 41/43] travis: Stop building and testing rust Instead, only run `make tidy`. The tidy script can run quite quickly, and it's super annoying to run tests for 50 minutes only to have bors fail with a "trailing whitespace" error. --- .travis.yml | 63 ++++++++++------------------------------------------- 1 file changed, 11 insertions(+), 52 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd62defa020..354cb969edd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,60 +1,19 @@ # Use something that's not 'ruby' so we don't set up things like -# RVM/bundler/ruby and whatnot. Right now 'rust' isn't a language on travis and -# it treats unknown languages as ruby-like I believe. +# RVM/bundler/ruby and whatnot. Right now 'rust' as a language actually +# downloads a rust/cargo snapshot, which we don't really want for building rust. language: c -# Before we start doing anything, install a stock LLVM -install: - - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.4 main' >> /etc/apt/sources.list" - - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list" - - sudo sh -c "echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main' >> /etc/apt/sources.list" - - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - - - sudo apt-get update -qq - - sudo apt-get install -qq --force-yes -y llvm-$LLVM_VERSION - llvm-${LLVM_VERSION}-dev clang-$LLVM_VERSION lldb-$LLVM_VERSION - - -# All of the llvm tools are suffixed with "-$VERS" which we don't want, so -# symlink them all into a local directory and just use that +# The test suite is in general way too stressful for travis, especially in +# terms of time limit and reliability. In the past we've tried to scale things +# back to only build the stage1 compiler and run a subset of tests, but this +# didn't end up panning out very well. # -# FIXME: this shouldn't update the src/llvm sub-repo, that takes about a minute -# it's gotta download so much stuff. +# As a result, we're just using travis to run `make tidy` now. It'll help +# everyone find out about their trailing spaces early on! before_script: - - mkdir -p local-llvm/bin - - ln -nsf /usr/bin/llvm-config-$LLVM_VERSION local-llvm/bin/llvm-config - - ln -nsf /usr/bin/llvm-mc-$LLVM_VERSION local-llvm/bin/llvm-mc - - ln -nsf /usr/bin/llvm-as-$LLVM_VERSION local-llvm/bin/llvm-as - - ln -nsf /usr/bin/llvm-dis-$LLVM_VERSION local-llvm/bin/llvm-dis - - ln -nsf /usr/bin/llc-$LLVM_VERSION local-llvm/bin/llc - - ln -nsf /usr/include/llvm-$LLVM_VERSION local-llvm/include - - ./configure --disable-optimize-tests --llvm-root=`pwd`/local-llvm - --enable-fast-make --enable-clang - -# Tidy everything up first, then build a few things, and then run a few tests. -# Note that this is meant to run in a "fairly small" amount of time, so this -# isn't exhaustive at all. -# -# As a result of https://github.com/travis-ci/travis-ci/issues/1066, we run -# everything in one large command instead of multiple commands. -script: | - if [[ $TRAVIS_PULL_REQUEST != 'false' ]]; then - if [[ $LLVM_VERSION != '3.4' ]]; then exit 0; fi - fi && - make tidy && - make -j4 rustc-stage1 RUSTFLAGS='-Z time-passes' && - make check-stage1-std check-stage1-rpass check-stage1-cfail check-stage1-rfail check-stage1-doc - -env: - global: - - NO_BENCH=1 - matrix: - - LLVM_VERSION=3.3 - - LLVM_VERSION=3.4 - -# We track this ourselves, and in theory we don't have to update the LLVM repo -# (but sadly we do right now anyway). -git: - submodules: false + - ./configure +script: + - make tidy notifications: email: false From 9ac804ecabe3800a16941691bb1eb90293fd2606 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 2 Oct 2014 13:50:43 -0700 Subject: [PATCH 42/43] travis: Stop building and testing rust Instead, only run `make tidy`. The tidy script can run quite quickly, and it's super annoying to run tests for 50 minutes only to have bors fail with a "trailing whitespace" error. --- .travis.yml | 68 +++++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 49 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd62defa020..e8d74c0eb1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,64 +1,34 @@ # Use something that's not 'ruby' so we don't set up things like -# RVM/bundler/ruby and whatnot. Right now 'rust' isn't a language on travis and -# it treats unknown languages as ruby-like I believe. +# RVM/bundler/ruby and whatnot. Right now 'rust' as a language actually +# downloads a rust/cargo snapshot, which we don't really want for building rust. language: c -# Before we start doing anything, install a stock LLVM +# Make sure we've got an up-to-date g++ compiler to get past the LLVM configure +# script. install: - - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.4 main' >> /etc/apt/sources.list" - - sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list" - - sudo sh -c "echo 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main' >> /etc/apt/sources.list" - - wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - + - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test - sudo apt-get update -qq - - sudo apt-get install -qq --force-yes -y llvm-$LLVM_VERSION - llvm-${LLVM_VERSION}-dev clang-$LLVM_VERSION lldb-$LLVM_VERSION + - sudo apt-get install g++-4.7 - -# All of the llvm tools are suffixed with "-$VERS" which we don't want, so -# symlink them all into a local directory and just use that +# The test suite is in general way too stressful for travis, especially in +# terms of time limit and reliability. In the past we've tried to scale things +# back to only build the stage1 compiler and run a subset of tests, but this +# didn't end up panning out very well. # -# FIXME: this shouldn't update the src/llvm sub-repo, that takes about a minute -# it's gotta download so much stuff. +# As a result, we're just using travis to run `make tidy` now. It'll help +# everyone find out about their trailing spaces early on! before_script: - - mkdir -p local-llvm/bin - - ln -nsf /usr/bin/llvm-config-$LLVM_VERSION local-llvm/bin/llvm-config - - ln -nsf /usr/bin/llvm-mc-$LLVM_VERSION local-llvm/bin/llvm-mc - - ln -nsf /usr/bin/llvm-as-$LLVM_VERSION local-llvm/bin/llvm-as - - ln -nsf /usr/bin/llvm-dis-$LLVM_VERSION local-llvm/bin/llvm-dis - - ln -nsf /usr/bin/llc-$LLVM_VERSION local-llvm/bin/llc - - ln -nsf /usr/include/llvm-$LLVM_VERSION local-llvm/include - - ./configure --disable-optimize-tests --llvm-root=`pwd`/local-llvm - --enable-fast-make --enable-clang - -# Tidy everything up first, then build a few things, and then run a few tests. -# Note that this is meant to run in a "fairly small" amount of time, so this -# isn't exhaustive at all. -# -# As a result of https://github.com/travis-ci/travis-ci/issues/1066, we run -# everything in one large command instead of multiple commands. -script: | - if [[ $TRAVIS_PULL_REQUEST != 'false' ]]; then - if [[ $LLVM_VERSION != '3.4' ]]; then exit 0; fi - fi && - make tidy && - make -j4 rustc-stage1 RUSTFLAGS='-Z time-passes' && - make check-stage1-std check-stage1-rpass check-stage1-cfail check-stage1-rfail check-stage1-doc - -env: - global: - - NO_BENCH=1 - matrix: - - LLVM_VERSION=3.3 - - LLVM_VERSION=3.4 - -# We track this ourselves, and in theory we don't have to update the LLVM repo -# (but sadly we do right now anyway). -git: - submodules: false + - ./configure --llvm-root=`pwd`/local-llvm +script: + - make tidy notifications: email: false +env: + global: + - LLVM_VERSION=3.4 + branches: only: - master From f96ee10e888bac4435973972f1799db509b3318e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 2 Oct 2014 15:12:58 -0700 Subject: [PATCH 43/43] Test fixes from the rollup --- src/liballoc/heap.rs | 1 + src/libgreen/basic.rs | 4 +- src/test/bench/task-perf-alloc-unwind.rs | 4 +- src/test/debuginfo/borrowed-struct.rs | 12 +++--- src/test/debuginfo/borrowed-tuple.rs | 4 +- src/test/debuginfo/boxed-struct.rs | 4 +- src/test/debuginfo/recursive-struct.rs | 32 +++++++-------- src/test/debuginfo/simd.rs | 40 +++++++++---------- .../var-captured-in-nested-closure.rs | 14 +++---- src/test/pretty/block-disambig.rs | 2 +- src/test/run-pass/issue-13167.rs | 2 +- 11 files changed, 60 insertions(+), 59 deletions(-) diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 72384e25c3b..ef3ccd5aead 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -344,6 +344,7 @@ mod imp { mod test { extern crate test; use self::test::Bencher; + use heap; #[test] fn basic_reallocate_inplace_noop() { diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs index 129d37638a3..4bb4eeb4950 100644 --- a/src/libgreen/basic.rs +++ b/src/libgreen/basic.rs @@ -73,13 +73,13 @@ impl BasicLoop { RunRemote(i) => { match self.remotes.iter_mut().find(|& &(id, _)| id == i) { Some(&(_, ref mut f)) => f.call(), - None => unreachable!() + None => fail!("bad remote: {}", i), } } RemoveRemote(i) => { match self.remotes.iter().position(|&(id, _)| id == i) { Some(i) => { self.remotes.remove(i).unwrap(); } - None => unreachable!() + None => fail!("bad remote: {}", i), } } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 6729373296b..a86b797544a 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -89,8 +89,8 @@ fn recurse_or_fail(depth: int, st: Option) { State { unique: box Cons((), box *st.unique), vec: st.vec.clone().append( - &[box Cons((), *st.vec.last().unwrap())]), - res: r(box Cons((), st.res._l)) + &[box Cons((), st.vec.last().unwrap().clone())]), + res: r(box Cons((), st.res._l.clone())) } } }; diff --git a/src/test/debuginfo/borrowed-struct.rs b/src/test/debuginfo/borrowed-struct.rs index 8b9c790bbbf..f0c63bfed02 100644 --- a/src/test/debuginfo/borrowed-struct.rs +++ b/src/test/debuginfo/borrowed-struct.rs @@ -30,13 +30,13 @@ // gdb-check:$4 = {x = 11, y = 24.5} // gdb-command:print *unique_val_ref -// gdb-check:$8 = {x = 13, y = 26.5} +// gdb-check:$5 = {x = 13, y = 26.5} // gdb-command:print *unique_val_interior_ref_1 -// gdb-check:$9 = 13 +// gdb-check:$6 = 13 // gdb-command:print *unique_val_interior_ref_2 -// gdb-check:$10 = 26.5 +// gdb-check:$7 = 26.5 // === LLDB TESTS ================================================================================== @@ -56,13 +56,13 @@ // lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 } // lldb-command:print *unique_val_ref -// lldb-check:[...]$7 = SomeStruct { x: 13, y: 26.5 } +// lldb-check:[...]$4 = SomeStruct { x: 13, y: 26.5 } // lldb-command:print *unique_val_interior_ref_1 -// lldb-check:[...]$8 = 13 +// lldb-check:[...]$5 = 13 // lldb-command:print *unique_val_interior_ref_2 -// lldb-check:[...]$9 = 26.5 +// lldb-check:[...]$6 = 26.5 #![allow(unused_variable)] diff --git a/src/test/debuginfo/borrowed-tuple.rs b/src/test/debuginfo/borrowed-tuple.rs index 2c78d14a86c..e7b06af66fb 100644 --- a/src/test/debuginfo/borrowed-tuple.rs +++ b/src/test/debuginfo/borrowed-tuple.rs @@ -26,7 +26,7 @@ // gdb-check:$2 = {-15, -20} // gdb-command:print *unique_val_ref -// gdb-check:$4 = {-17, -22} +// gdb-check:$3 = {-17, -22} // === LLDB TESTS ================================================================================== @@ -40,7 +40,7 @@ // lldb-check:[...]$1 = (-15, -20) // lldb-command:print *unique_val_ref -// lldb-check:[...]$3 = (-17, -22) +// lldb-check:[...]$2 = (-17, -22) #![allow(unused_variable)] diff --git a/src/test/debuginfo/boxed-struct.rs b/src/test/debuginfo/boxed-struct.rs index a22b9fdea5c..120553442fc 100644 --- a/src/test/debuginfo/boxed-struct.rs +++ b/src/test/debuginfo/boxed-struct.rs @@ -22,7 +22,7 @@ // gdb-check:$1 = {x = 99, y = 999, z = 9999, w = 99999} // gdb-command:print *unique_dtor -// gdb-check:$3 = {x = 77, y = 777, z = 7777, w = 77777} +// gdb-check:$2 = {x = 77, y = 777, z = 7777, w = 77777} // === LLDB TESTS ================================================================================== @@ -33,7 +33,7 @@ // lldb-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 } // lldb-command:print *unique_dtor -// lldb-check:[...]$2 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 } +// lldb-check:[...]$1 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 } #![allow(unused_variable)] diff --git a/src/test/debuginfo/recursive-struct.rs b/src/test/debuginfo/recursive-struct.rs index 412bdfaaf15..40c056f5cd2 100644 --- a/src/test/debuginfo/recursive-struct.rs +++ b/src/test/debuginfo/recursive-struct.rs @@ -30,45 +30,45 @@ // gdb-check:$4 = 3 // gdb-command:print vec_unique[0].value -// gdb-check:$7 = 6.5 +// gdb-check:$5 = 6.5 // gdb-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value -// gdb-check:$8 = 7.5 +// gdb-check:$6 = 7.5 // gdb-command:print borrowed_unique->value -// gdb-check:$9 = 8.5 +// gdb-check:$7 = 8.5 // gdb-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value -// gdb-check:$10 = 9.5 +// gdb-check:$8 = 9.5 // LONG CYCLE // gdb-command:print long_cycle1.value -// gdb-check:$21 = 20 +// gdb-check:$9 = 20 // gdb-command:print long_cycle1.next->value -// gdb-check:$22 = 21 +// gdb-check:$10 = 21 // gdb-command:print long_cycle1.next->next->value -// gdb-check:$23 = 22 +// gdb-check:$11 = 22 // gdb-command:print long_cycle1.next->next->next->value -// gdb-check:$24 = 23 +// gdb-check:$12 = 23 // gdb-command:print long_cycle2.value -// gdb-check:$25 = 24 +// gdb-check:$13 = 24 // gdb-command:print long_cycle2.next->value -// gdb-check:$26 = 25 +// gdb-check:$14 = 25 // gdb-command:print long_cycle2.next->next->value -// gdb-check:$27 = 26 +// gdb-check:$15 = 26 // gdb-command:print long_cycle3.value -// gdb-check:$28 = 27 +// gdb-check:$16 = 27 // gdb-command:print long_cycle3.next->value -// gdb-check:$29 = 28 +// gdb-check:$17 = 28 // gdb-command:print long_cycle4.value -// gdb-check:$30 = 29.5 +// gdb-check:$18 = 29.5 // gdb-command:print (*****long_cycle_w_anonymous_types).value -// gdb-check:$31 = 30 +// gdb-check:$19 = 30 // gdb-command:print (*****((*****long_cycle_w_anonymous_types).next.RUST$ENCODED$ENUM$0$Empty.val)).value -// gdb-check:$32 = 31 +// gdb-check:$20 = 31 // gdb-command:continue diff --git a/src/test/debuginfo/simd.rs b/src/test/debuginfo/simd.rs index eee1d0e70ca..e355327a5ef 100644 --- a/src/test/debuginfo/simd.rs +++ b/src/test/debuginfo/simd.rs @@ -18,27 +18,27 @@ // gdb-command:run // gdb-command:finish -// gdb-command:print/d i8x16 +// gdb-command:print/d vi8x16 // gdb-check:$1 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} -// gdb-command:print/d i16x8 +// gdb-command:print/d vi16x8 // gdb-check:$2 = {16, 17, 18, 19, 20, 21, 22, 23} -// gdb-command:print/d i32x4 +// gdb-command:print/d vi32x4 // gdb-check:$3 = {24, 25, 26, 27} -// gdb-command:print/d i64x2 +// gdb-command:print/d vi64x2 // gdb-check:$4 = {28, 29} -// gdb-command:print/d u8x16 +// gdb-command:print/d vu8x16 // gdb-check:$5 = {30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45} -// gdb-command:print/d u16x8 +// gdb-command:print/d vu16x8 // gdb-check:$6 = {46, 47, 48, 49, 50, 51, 52, 53} -// gdb-command:print/d u32x4 +// gdb-command:print/d vu32x4 // gdb-check:$7 = {54, 55, 56, 57} -// gdb-command:print/d u64x2 +// gdb-command:print/d vu64x2 // gdb-check:$8 = {58, 59} -// gdb-command:print f32x4 +// gdb-command:print vf32x4 // gdb-check:$9 = {60.5, 61.5, 62.5, 63.5} -// gdb-command:print f64x2 +// gdb-command:print vf64x2 // gdb-check:$10 = {64.5, 65.5} // gdb-command:continue @@ -50,21 +50,21 @@ use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2}; fn main() { - let i8x16 = i8x16(0i8, 1i8, 2i8, 3i8, 4i8, 5i8, 6i8, 7i8, + let vi8x16 = i8x16(0i8, 1i8, 2i8, 3i8, 4i8, 5i8, 6i8, 7i8, 8i8, 9i8, 10i8, 11i8, 12i8, 13i8, 14i8, 15i8); - let i16x8 = i16x8(16i16, 17i16, 18i16, 19i16, 20i16, 21i16, 22i16, 23i16); - let i32x4 = i32x4(24i32, 25i32, 26i32, 27i32); - let i64x2 = i64x2(28i64, 29i64); + let vi16x8 = i16x8(16i16, 17i16, 18i16, 19i16, 20i16, 21i16, 22i16, 23i16); + let vi32x4 = i32x4(24i32, 25i32, 26i32, 27i32); + let vi64x2 = i64x2(28i64, 29i64); - let u8x16 = u8x16(30u8, 31u8, 32u8, 33u8, 34u8, 35u8, 36u8, 37u8, + let vu8x16 = u8x16(30u8, 31u8, 32u8, 33u8, 34u8, 35u8, 36u8, 37u8, 38u8, 39u8, 40u8, 41u8, 42u8, 43u8, 44u8, 45u8); - let u16x8 = u16x8(46u16, 47u16, 48u16, 49u16, 50u16, 51u16, 52u16, 53u16); - let u32x4 = u32x4(54u32, 55u32, 56u32, 57u32); - let u64x2 = u64x2(58u64, 59u64); + let vu16x8 = u16x8(46u16, 47u16, 48u16, 49u16, 50u16, 51u16, 52u16, 53u16); + let vu32x4 = u32x4(54u32, 55u32, 56u32, 57u32); + let vu64x2 = u64x2(58u64, 59u64); - let f32x4 = f32x4(60.5f32, 61.5f32, 62.5f32, 63.5f32); - let f64x2 = f64x2(64.5f64, 65.5f64); + let vf32x4 = f32x4(60.5f32, 61.5f32, 62.5f32, 63.5f32); + let vf64x2 = f64x2(64.5f64, 65.5f64); zzz(); } diff --git a/src/test/debuginfo/var-captured-in-nested-closure.rs b/src/test/debuginfo/var-captured-in-nested-closure.rs index 89415df3588..d72f9256883 100644 --- a/src/test/debuginfo/var-captured-in-nested-closure.rs +++ b/src/test/debuginfo/var-captured-in-nested-closure.rs @@ -29,22 +29,22 @@ // gdb-command:print *owned // gdb-check:$5 = 6 // gdb-command:print closure_local -// gdb-check:$7 = 8 +// gdb-check:$6 = 8 // gdb-command:continue // gdb-command:finish // gdb-command:print variable -// gdb-check:$8 = 1 +// gdb-check:$7 = 1 // gdb-command:print constant -// gdb-check:$9 = 2 +// gdb-check:$8 = 2 // gdb-command:print a_struct -// gdb-check:$10 = {a = -3, b = 4.5, c = 5} +// gdb-check:$9 = {a = -3, b = 4.5, c = 5} // gdb-command:print *struct_ref -// gdb-check:$11 = {a = -3, b = 4.5, c = 5} +// gdb-check:$10 = {a = -3, b = 4.5, c = 5} // gdb-command:print *owned -// gdb-check:$12 = 6 +// gdb-check:$11 = 6 // gdb-command:print closure_local -// gdb-check:$14 = 8 +// gdb-check:$12 = 8 // gdb-command:continue diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 01fc70c1d2c..1b1765475f3 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -60,7 +60,7 @@ fn test9() { fn test10() -> int { let regs = vec!(0i); match true { true => { } _ => { } } - *(*regs).get(0) + regs[0] } fn test11() -> Vec { if true { } vec!(1, 2) } diff --git a/src/test/run-pass/issue-13167.rs b/src/test/run-pass/issue-13167.rs index 1a58a6842d4..be3ee0e0783 100644 --- a/src/test/run-pass/issue-13167.rs +++ b/src/test/run-pass/issue-13167.rs @@ -10,7 +10,7 @@ use std::slice; -pub struct PhfMapEntries<'a, T> { +pub struct PhfMapEntries<'a, T: 'a> { iter: slice::Items<'a, (&'static str, T)>, }