Skip to content

Commit

Permalink
Update docs to include Sized trait, which is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Sep 15, 2014
1 parent 48bc291 commit eafeb33
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/doc/guide-unsafe.md
Expand Up @@ -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!
```

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

13 comments on commit eafeb33

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@eafeb33

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-5527-trait-reform-revisited = eafeb33 into auto

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-5527-trait-reform-revisited = eafeb33 merged ok, testing candidate = dd86f9d

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@eafeb33

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-5527-trait-reform-revisited = eafeb33 into auto

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-5527-trait-reform-revisited = eafeb33 merged ok, testing candidate = 57ed294b

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@eafeb33

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-5527-trait-reform-revisited = eafeb33 into auto

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-5527-trait-reform-revisited = eafeb33 merged ok, testing candidate = 946654a

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on eafeb33 Sep 16, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 946654a

Please sign in to comment.