diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-09-15 18:52:20 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-09-15 18:52:20 -0400 |
| commit | eafeb335a0731b4bfcd8be6203d0d29a3668cd76 (patch) | |
| tree | 4edb6839e8a55363152701961485f077beb07ef0 /src | |
| parent | 48bc291a80085978987d13f75b70b82b69ec9b4d (diff) | |
| download | rust-eafeb335a0731b4bfcd8be6203d0d29a3668cd76.tar.gz rust-eafeb335a0731b4bfcd8be6203d0d29a3668cd76.zip | |
Update docs to include Sized trait, which is needed
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/guide-unsafe.md | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index a95401682cf..8c67634d57a 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -461,11 +461,12 @@ fn start(_argc: int, _argv: *const *const u8) -> int { 0 } -// These functions are invoked by the compiler, but not +// These functions and traits are used by the compiler, but not // for a bare-bones hello world. These are normally // provided by libstd. #[lang = "stack_exhausted"] extern fn stack_exhausted() {} #[lang = "eh_personality"] extern fn eh_personality() {} +#[lang = "sized"] trait Sized { } # // fn main() {} tricked you, rustdoc! ``` @@ -488,13 +489,14 @@ 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 { } # // 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 -library, but without it you must define your own. +xlibrary, but without it you must define your own. The first of these two functions, `stack_exhausted`, is invoked whenever stack overflow is detected. This function has a number of restrictions about how it @@ -508,6 +510,12 @@ mechanisms of the compiler. This is often mapped to GCC's personality function 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. + ## Using libcore > **Note**: the core library's structure is unstable, and it is recommended to @@ -686,6 +694,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 {} ``` Note the use of `abort`: the `exchange_malloc` lang item is assumed to |
