From 6473909a1b1ff5c435d75d4df844c4b08dafcee9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 25 Sep 2014 13:59:24 -0400 Subject: [PATCH] Fix various places that were affected by adding core as dep of libc --- src/doc/guide-unsafe.md | 28 ++++++++++------------ src/test/run-make/no-duplicate-libs/bar.rs | 1 + src/test/run-make/no-duplicate-libs/foo.rs | 1 + src/test/run-pass/smallest-hello-world.rs | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index ba79e828150..1e67c8a13e9 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -466,7 +466,7 @@ fn start(_argc: int, _argv: *const *const u8) -> int { // provided by libstd. #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "sized"] trait Sized { } +#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } # // fn main() {} tricked you, rustdoc! ``` @@ -489,32 +489,28 @@ pub extern fn main(argc: int, argv: *const *const u8) -> int { #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "sized"] trait Sized { } +#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } # // fn main() {} tricked you, rustdoc! ``` The compiler currently makes a few assumptions about symbols which are available in the executable to call. Normally these functions are provided by the standard -xlibrary, but without it you must define your own. +library, but without it you must define your own. -The first of these two functions, `stack_exhausted`, is invoked whenever stack +The first of these three functions, `stack_exhausted`, is invoked whenever stack overflow is detected. This function has a number of restrictions about how it can be called and what it must do, but if the stack limit register is not being maintained then a task always has an "infinite stack" and this function shouldn't get triggered. -The second of these two functions, `eh_personality`, is used by the failure -mechanisms of the compiler. This is often mapped to GCC's personality function -(see the [libstd implementation](std/rt/unwind/index.html) for more -information), but crates which do not trigger failure can be assured that this -function is never called. - -The final item in the example is a trait called `Sized`. This a trait -that represents data of a known static size: it is integral to the -Rust type system, and so the compiler expects the standard library to -provide it. Since you are not using the standard library, you have to -provide it yourself. +The second of these three functions, `eh_personality`, is used by the +failure mechanisms of the compiler. This is often mapped to GCC's +personality function (see the +[libstd implementation](std/rt/unwind/index.html) for more +information), but crates which do not trigger failure can be assured +that this function is never called. The final function, `fail_fmt`, is +also used by the failure mechanisms of the compiler. ## Using libcore @@ -694,7 +690,7 @@ fn main(argc: int, argv: *const *const u8) -> int { #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "sized"] trait Sized {} +#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } ``` Note the use of `abort`: the `exchange_malloc` lang item is assumed to diff --git a/src/test/run-make/no-duplicate-libs/bar.rs b/src/test/run-make/no-duplicate-libs/bar.rs index 8b87b5f0f9a..721d16b4810 100644 --- a/src/test/run-make/no-duplicate-libs/bar.rs +++ b/src/test/run-make/no-duplicate-libs/bar.rs @@ -19,3 +19,4 @@ pub extern fn bar() {} #[lang = "stack_exhausted"] fn stack_exhausted() {} #[lang = "eh_personality"] fn eh_personality() {} +#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } diff --git a/src/test/run-make/no-duplicate-libs/foo.rs b/src/test/run-make/no-duplicate-libs/foo.rs index 6f9537c1f44..3382cc20799 100644 --- a/src/test/run-make/no-duplicate-libs/foo.rs +++ b/src/test/run-make/no-duplicate-libs/foo.rs @@ -19,3 +19,4 @@ pub extern fn foo() {} #[lang = "stack_exhausted"] fn stack_exhausted() {} #[lang = "eh_personality"] fn eh_personality() {} +#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } diff --git a/src/test/run-pass/smallest-hello-world.rs b/src/test/run-pass/smallest-hello-world.rs index 52e71186537..fdddac6bc37 100644 --- a/src/test/run-pass/smallest-hello-world.rs +++ b/src/test/run-pass/smallest-hello-world.rs @@ -22,7 +22,7 @@ extern "rust-intrinsic" { fn transmute(t: T) -> U; } #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} -#[lang = "sized"] pub trait Sized {} +#[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } #[start] #[no_split_stack]