@@ -466,7 +466,7 @@ fn start(_argc: int, _argv: *const *const u8) -> int {
466
466
// provided by libstd.
467
467
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
468
468
#[lang = "eh_personality"] extern fn eh_personality() {}
469
- #[lang = "sized "] trait Sized { }
469
+ #[lang = "fail_fmt "] fn fail_fmt() -> ! { loop {} }
470
470
# // fn main() {} tricked you, rustdoc!
471
471
```
472
472
@@ -489,32 +489,28 @@ pub extern fn main(argc: int, argv: *const *const u8) -> int {
489
489
490
490
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
491
491
#[lang = "eh_personality"] extern fn eh_personality() {}
492
- #[lang = "sized "] trait Sized { }
492
+ #[lang = "fail_fmt "] fn fail_fmt() -> ! { loop {} }
493
493
# // fn main() {} tricked you, rustdoc!
494
494
```
495
495
496
496
497
497
The compiler currently makes a few assumptions about symbols which are available
498
498
in the executable to call. Normally these functions are provided by the standard
499
- xlibrary , but without it you must define your own.
499
+ library , but without it you must define your own.
500
500
501
- The first of these two functions, ` stack_exhausted ` , is invoked whenever stack
501
+ The first of these three functions, ` stack_exhausted ` , is invoked whenever stack
502
502
overflow is detected. This function has a number of restrictions about how it
503
503
can be called and what it must do, but if the stack limit register is not being
504
504
maintained then a task always has an "infinite stack" and this function
505
505
shouldn't get triggered.
506
506
507
- The second of these two functions, ` eh_personality ` , is used by the failure
508
- mechanisms of the compiler. This is often mapped to GCC's personality function
509
- (see the [ libstd implementation] ( std/rt/unwind/index.html ) for more
510
- information), but crates which do not trigger failure can be assured that this
511
- function is never called.
512
-
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.
507
+ The second of these three functions, ` eh_personality ` , is used by the
508
+ failure mechanisms of the compiler. This is often mapped to GCC's
509
+ personality function (see the
510
+ [ libstd implementation] ( std/rt/unwind/index.html ) for more
511
+ information), but crates which do not trigger failure can be assured
512
+ that this function is never called. The final function, ` fail_fmt ` , is
513
+ also used by the failure mechanisms of the compiler.
518
514
519
515
## Using libcore
520
516
@@ -573,8 +569,8 @@ pub extern fn dot_product(a: *const u32, a_len: u32,
573
569
return ret;
574
570
}
575
571
576
- #[lang = "begin_unwind "]
577
- extern fn begin_unwind (args: &core::fmt::Arguments,
572
+ #[lang = "fail_fmt "]
573
+ extern fn fail_fmt (args: &core::fmt::Arguments,
578
574
file: &str,
579
575
line: uint) -> ! {
580
576
loop {}
@@ -587,8 +583,8 @@ extern fn begin_unwind(args: &core::fmt::Arguments,
587
583
```
588
584
589
585
Note that there is one extra lang item here which differs from the examples
590
- above, ` begin_unwind ` . This must be defined by consumers of libcore because the
591
- core library declares failure, but it does not define it. The ` begin_unwind `
586
+ above, ` fail_fmt ` . This must be defined by consumers of libcore because the
587
+ core library declares failure, but it does not define it. The ` fail_fmt `
592
588
lang item is this crate's definition of failure, and it must be guaranteed to
593
589
never return.
594
590
@@ -694,7 +690,7 @@ fn main(argc: int, argv: *const *const u8) -> int {
694
690
695
691
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
696
692
#[lang = "eh_personality"] extern fn eh_personality() {}
697
- #[lang = "sized "] trait Sized { }
693
+ #[lang = "fail_fmt "] fn fail_fmt() -> ! { loop {} }
698
694
```
699
695
700
696
Note the use of ` abort ` : the ` exchange_malloc ` lang item is assumed to
@@ -706,7 +702,7 @@ Other features provided by lang items include:
706
702
` == ` , ` < ` , dereferencing (` * ` ) and ` + ` (etc.) operators are all
707
703
marked with lang items; those specific four are ` eq ` , ` ord ` ,
708
704
` deref ` , and ` add ` respectively.
709
- - stack unwinding and general failure; the ` eh_personality ` , ` fail_ `
705
+ - stack unwinding and general failure; the ` eh_personality ` , ` fail `
710
706
and ` fail_bounds_checks ` lang items.
711
707
- the traits in ` std::kinds ` used to indicate types that satisfy
712
708
various kinds; lang items ` send ` , ` sync ` and ` copy ` .
0 commit comments