Skip to content

Commit eafeb33

Browse files
committed
Update docs to include Sized trait, which is needed
1 parent 48bc291 commit eafeb33

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/doc/guide-unsafe.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ fn start(_argc: int, _argv: *const *const u8) -> int {
461461
0
462462
}
463463
464-
// These functions are invoked by the compiler, but not
464+
// These functions and traits are used by the compiler, but not
465465
// for a bare-bones hello world. These are normally
466466
// provided by libstd.
467467
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
468468
#[lang = "eh_personality"] extern fn eh_personality() {}
469+
#[lang = "sized"] trait Sized { }
469470
# // fn main() {} tricked you, rustdoc!
470471
```
471472

@@ -488,13 +489,14 @@ pub extern fn main(argc: int, argv: *const *const u8) -> int {
488489
489490
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
490491
#[lang = "eh_personality"] extern fn eh_personality() {}
492+
#[lang = "sized"] trait Sized { }
491493
# // fn main() {} tricked you, rustdoc!
492494
```
493495

494496

495497
The compiler currently makes a few assumptions about symbols which are available
496498
in the executable to call. Normally these functions are provided by the standard
497-
library, but without it you must define your own.
499+
xlibrary, but without it you must define your own.
498500

499501
The first of these two functions, `stack_exhausted`, is invoked whenever stack
500502
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
508510
information), but crates which do not trigger failure can be assured that this
509511
function is never called.
510512

513+
The final item in the example is a trait called `Sized`. This a trait
514+
that represents data of a known static size: it is integral to the
515+
Rust type system, and so the compiler expects the standard library to
516+
provide it. Since you are not using the standard library, you have to
517+
provide it yourself.
518+
511519
## Using libcore
512520

513521
> **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 {
686694
687695
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
688696
#[lang = "eh_personality"] extern fn eh_personality() {}
697+
#[lang = "sized"] trait Sized {}
689698
```
690699

691700
Note the use of `abort`: the `exchange_malloc` lang item is assumed to

0 commit comments

Comments
 (0)