about summary refs log tree commit diff
path: root/src/doc/guide-unsafe.md
AgeCommit message (Collapse)AuthorLines
2015-01-16Grammar tweak to old guide stub documents.Tim Parenti-1/+1
Removes extra "the" from the phrase "the the Rust Programming Language book", which isn't particularly grammatical.
2015-01-09Add stub deprecation files for each of the old guides.Huon Wilson-0/+4
There are hundreds of stackoverflow answers, reddit posts and blog articles that link to these documents, so it's a nicer user experience if they're not plain 404s. The intention is to let these hang around only for relatively short while. The alpha is likely to bring in many new users and they will be reading the documents mentioned above.
2015-01-08"The Rust Programming Language"Steve Klabnik-716/+0
This pulls all of our long-form documentation into a single document, nicknamed "the book" and formally titled "The Rust Programming Language." A few things motivated this change: * People knew of The Guide, but not the individual Guides. This merges them together, helping discoverability. * You can get all of Rust's longform documentation in one place, which is nice. * We now have rustbook in-tree, which can generate this kind of documentation. While its style is basic, the general idea is much better: a table of contents on the left-hand side. * Rather than a almost 10,000-line guide.md, there are now smaller files per section.
2015-01-07Test fixes and rebase conflictsAlex Crichton-2/+3
2015-01-07Change `std::kinds` to `std::markers`; flatten `std::kinds::marker`Nick Cameron-2/+2
[breaking-change]
2014-12-08librustc: Make `Copy` opt-in.Niko Matsakis-0/+3
This change makes the compiler no longer infer whether types (structures and enumerations) implement the `Copy` trait (and thus are implicitly copyable). Rather, you must implement `Copy` yourself via `impl Copy for MyType {}`. A new warning has been added, `missing_copy_implementations`, to warn you if a non-generic public type has been added that could have implemented `Copy` but didn't. For convenience, you may *temporarily* opt out of this behavior by using `#![feature(opt_out_copy)]`. Note though that this feature gate will never be accepted and will be removed by the time that 1.0 is released, so you should transition your code away from using it. This breaks code like: #[deriving(Show)] struct Point2D { x: int, y: int, } fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } Change this code to: #[deriving(Show)] struct Point2D { x: int, y: int, } impl Copy for Point2D {} fn main() { let mypoint = Point2D { x: 1, y: 1, }; let otherpoint = mypoint; println!("{}{}", mypoint, otherpoint); } This is the backwards-incompatible part of #13231. Part of RFC #3. [breaking-change]
2014-11-26Lifetime guide -> ownership guideSteve Klabnik-1/+1
2014-10-29Update infrastructure for fail -> panicSteve Klabnik-9/+9
This includes updating the language items and marking what needs to change after a snapshot. If you do not use the standard library, the language items you need to implement have changed. For example: ```rust #[lang = "fail_fmt"] fn fail_fmt() -> ! { loop {} } ``` is now ```rust #[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } ``` Related, lesser-implemented language items `fail` and `fail_bounds_check` have become `panic` and `panic_bounds_check`, as well. These are implemented by `libcore`, so it is unlikely (though possible!) that these two renamings will affect you. [breaking-change] Fix test suite
2014-10-29Rename fail! to panic!Steve Klabnik-2/+2
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-12Continue cfg syntax transitionSteven Fackler-9/+7
All deprecation warnings have been converted to errors. This includes the warning for multiple cfgs on one item. We'll leave that as an error for some period of time to ensure that all uses are updated before the behavior changes from "or" to "and".
2014-10-02docs: remove mentions of Gc.Eduard Burtescu-3/+1
2014-09-25Fix various places that were affected by adding core as dep of libcNiko Matsakis-16/+12
2014-09-25Rename `fail_` lang item to `fail`, closes #16114Florian Hahn-1/+1
2014-09-24Rename `begin_unwind` lang item to `fail_fmt`, refs #16114Florian Hahn-4/+4
2014-09-15Update docs to include Sized trait, which is neededNiko Matsakis-2/+11
2014-08-20doc: grammar fixesTshepang Lekhonkhobe-2/+2
2014-08-16librustc: Forbid external crates, imports, and/or items from beingPatrick Walton-1/+2
declared with the same name in the same scope. This breaks several common patterns. First are unused imports: use foo::bar; use baz::bar; Change this code to the following: use baz::bar; Second, this patch breaks globs that import names that are shadowed by subsequent imports. For example: use foo::*; // including `bar` use baz::bar; Change this code to remove the glob: use foo::{boo, quux}; use baz::bar; Or qualify all uses of `bar`: use foo::{boo, quux}; use baz; ... baz::bar ... Finally, this patch breaks code that, at top level, explicitly imports `std` and doesn't disable the prelude. extern crate std; Because the prelude imports `std` implicitly, there is no need to explicitly import it; just remove such directives. The old behavior can be opted into via the `import_shadowing` feature gate. Use of this feature gate is discouraged. This implements RFC #116. Closes #16464. [breaking-change]
2014-08-12guide-unsafe.md: fix wordingPhilipp Gesang-1/+1
Following a suggestion by Huon Wilson.
2014-08-12guide-unsafe.md: fix nounPhilipp Gesang-1/+1
2014-08-07Rename `Share` to `Sync`Alex Crichton-2/+2
This leaves the `Share` trait at `std::kinds` via a `#[deprecated]` `pub use` statement, but the `NoShare` struct is no longer part of `std::kinds::marker` due to #12660 (the build cannot bootstrap otherwise). All code referencing the `Share` trait should now reference the `Sync` trait, and all code referencing the `NoShare` type should now reference the `NoSync` type. The functionality and meaning of this trait have not changed, only the naming. Closes #16281 [breaking-change]
2014-08-01doc: Make sure all doc titles say 'Rust'. #12466Brian Anderson-1/+1
2014-06-29librustc: Remove the fallback to `int` for integers and `f64` forPatrick Walton-3/+3
floating point numbers for real. This will break code that looks like: let mut x = 0; while ... { x += 1; } println!("{}", x); Change that code to: let mut x = 0i; while ... { x += 1; } println!("{}", x); Closes #15201. [breaking-change]
2014-06-28Rename all raw pointers as necessaryAlex Crichton-16/+16
2014-06-25auto merge of #15165 : ↵bors-35/+33
zookoatleastauthoritycom/rust/14148-Optimize-out-exhortations-about-being-careful-2, r=huonw Yes, it is important to be careful, but repeated emphasis about it is probably not helpful — it starts to sound like you came for a tutorial but found a finger-wagging lecture. Even after I removed a few of these comments, there are still several left in the text. That's probably fine! A couple of mentions of how this is dangerous and you ought to be careful may be a good reminder to the reader. After making the edits, I reflowed the paragraphs that I had touched, using emacs's "M-x fill-paragraph", with fill-column equal to 70.
2014-06-25Optimize out exhortations about being careful.Zooko Wilcox-O'Hearn-35/+33
Yes, it is important to be careful, but repeated emphasis about it is probably not helpful — it starts to sound like you came for a tutorial but found a finger-wagging lecture. Even after I removed a few of these comments, there are still several left in the text. That's probably fine! A couple of mentions of how this is dangerous and you ought to be careful may be a good reminder to the reader. After making the edits, I reflowed the paragraphs that I had touched, using emacs's "M-x fill-paragraph", with fill-column equal to 70.
2014-06-23librustc: Feature gate lang items and intrinsics.Patrick Walton-0/+7
If you define lang items in your crate, add `#[feature(lang_items)]`. If you define intrinsics (`extern "rust-intrinsic"`), add `#[feature(intrinsics)]`. Closes #12858. [breaking-change]
2014-06-20librustc: Put `#[unsafe_destructor]` behind a feature gate.Patrick Walton-2/+6
Closes #8142. This is not the semantics we want long-term. You can continue to use `#[unsafe_destructor]`, but you'll need to add `#![feature(unsafe_destructor)]` to the crate attributes. [breaking-change]
2014-06-06doc: Turn off special features for rustdoc testsAlex Crichton-0/+1
These were only used for the markdown tests, and there's no reason they should be distinct from the other tests.
2014-06-04core: Apply stability attributes to ptr modBrian Anderson-2/+2
* null and mut_null are unstable. Their names may change if the unsafe pointer types change. * copy_memory and copy_overlapping_memory are unstable. We think they aren't going to change. * set_memory and zero_memory are experimental. Both the names and the semantics are under question. * swap and replace are unstable and probably won't change. * read is unstable, probably won't change * read_and_zero is experimental. It's necessity is in doubt. * mem::overwrite is now called ptr::write to match read and is unstable. mem::overwrite is now deprecated * array_each, array_each_with_len, buf_len, and position are all deprecated because they use old style iteration and their utility is generally under question.
2014-05-31rustdoc: Fix cross-crate links to reexported itemsAlex Crichton-1/+1
Cross crate links can target items which are not rendered in the documentation. If the item is reexported at a higher level, the destination of the link (a concatenation of the fully qualified name) may actually lead to nowhere. This fixes this problem by altering rustdoc to emit pages which redirect to the local copy of the reexported structure. cc #14515 Closes #14137
2014-05-31doc: Fix a number of broken linksAlex Crichton-4/+5
cc #14515
2014-05-22doc: Touch up the unsafe guideAlex Crichton-52/+144
* Change ~ references to Box * Rewrite examples so they can be compiled an run * Mention libcore * Update wording about compiler-required functions
2014-05-20core: Stabilize the mem moduleAlex Crichton-2/+2
Excluding the functions inherited from the cast module last week (with marked stability levels), these functions received the following treatment. * size_of - this method has become #[stable] * nonzero_size_of/nonzero_size_of_val - these methods have been removed * min_align_of - this method is now #[stable] * pref_align_of - this method has been renamed without the `pref_` prefix, and it is the "default alignment" now. This decision is in line with what clang does (see url linked in comment on function). This function is now #[stable]. * init - renamed to zeroed and marked #[stable] * uninit - marked #[stable] * move_val_init - renamed to overwrite and marked #[stable] * {from,to}_{be,le}{16,32,64} - all functions marked #[stable] * swap/replace/drop - marked #[stable] * size_of_val/min_align_of_val/align_of_val - these functions are marked #[unstable], but will continue to exist in some form. Concerns have been raised about their `_val` prefix. [breaking-change]
2014-05-11core: Remove the cast moduleAlex Crichton-2/+2
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-2/+2
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-01Fix a/an typosJorge Aparicio-1/+1
2014-04-15auto merge of #13498 : johnsoft/rust/fix-transmute-fn-names, r=alexcrichtonbors-1/+1
Regions were renamed to lifetimes a while back, so these functions should probably be renamed as well.
2014-04-14auto merge of #13477 : Manishearth/rust/newattr, r=brsonbors-8/+8
See #13476
2014-04-13Replace 'region' with 'lifetime' in a few transmute function namesJohn Simon-1/+1
2014-04-12Update tutorials to use new attribute syntax (#13476)Manish Goregaokar-8/+8
2014-04-06auto merge of #13315 : alexcrichton/rust/libc, r=alexcrichton,mebors-1/+2
Rebasing of #12526 with a very obscure bug fixed on windows.
2014-04-04Fix inner attribute syntax from `#[foo];` to `#![foo]`Timothée Ravier-6/+6
From the 0.10 changelog: * The inner attribute syntax has changed from `#[foo];` to `#![foo]`.
2014-04-04Fix fallout from std::libc separationCorey Richardson-1/+2
2014-03-31doc: Update with changes in field privacyAlex Crichton-1/+1
2014-03-28Rename Pod into CopyFlavio Percoco-1/+1
Summary: So far, we've used the term POD "Plain Old Data" to refer to types that can be safely copied. However, this term is not consistent with the other built-in bounds that use verbs instead. This patch renames the Pod kind into Copy. RFC: 0003-opt-in-builtin-traits Test Plan: make check Reviewers: cmr Differential Revision: http://phabricator.octayn.net/D3
2014-03-20Mention share in guide-unsafe instead of freezeFlavio Percoco-2/+2
2014-03-15docs: begin a "low-level & unsafe code" guide.Huon Wilson-0/+606
This aims to cover the basics of writing safe unsafe code. At the moment it is just designed to be a better place for the `asm!()` docs than the detailed release notes wiki page, and I took the time to write up some other things. More examples are needed, especially of things that can subtly go wrong; and vast areas of `unsafe`-ty aren't covered, e.g. `static mut`s and thread-safety in general.