about summary refs log tree commit diff
path: root/src/doc
AgeCommit message (Collapse)AuthorLines
2015-03-24rollup merge of #23638: pnkfelix/fsk-reject-specialized-dropsAlex Crichton-8/+9
Reject specialized Drop impls. See Issue #8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Fix #8142 Fix #23584
2015-03-24rollup merge of #23662: steveklabnik/gh23421Alex Crichton-3/+3
I assume since both shifts say the same thing, I should fix both of them, but then I realized I don't strictly know about left shift. Fixes #23421 r? @pnkfelix
2015-03-24rollup merge of #23629: liammonahan/masterAlex Crichton-2/+2
Found a small typo on the Rust book "ownership" page. Best, Liam r? @steveklabnik
2015-03-24rollup merge of #23573: steveklabnik/doc_associated_typesAlex Crichton-0/+203
2015-03-24Reject specialized Drop impls.Felix S. Klock II-8/+9
See Issue 8142 for discussion. This makes it illegal for a Drop impl to be more specialized than the original item. So for example, all of the following are now rejected (when they would have been blindly accepted before): ```rust struct S<A> { ... }; impl Drop for S<i8> { ... } // error: specialized to concrete type struct T<'a> { ... }; impl Drop for T<'static> { ... } // error: specialized to concrete region struct U<A> { ... }; impl<A:Clone> Drop for U<A> { ... } // error: added extra type requirement struct V<'a,'b>; impl<'a,'b:a> Drop for V<'a,'b> { ... } // error: added extra region requirement ``` Due to examples like the above, this is a [breaking-change]. (The fix is to either remove the specialization from the `Drop` impl, or to transcribe the requirements into the struct/enum definition; examples of both are shown in the PR's fixed to `libstd`.) ---- This is likely to be the last thing blocking the removal of the `#[unsafe_destructor]` attribute. Includes two new error codes for the new dropck check. Update run-pass tests to accommodate new dropck pass. Update tests and docs to reflect new destructor restriction. ---- Implementation notes: We identify Drop impl specialization by not being as parametric as the struct/enum definition via unification. More specifically: 1. Attempt unification of a skolemized instance of the struct/enum with an instance of the Drop impl's type expression where all of the impl's generics (i.e. the free variables of the type expression) have been replaced with unification variables. 2. If unification fails, then reject Drop impl as specialized. 3. If unification succeeds, check if any of the skolemized variables "leaked" into the constraint set for the inference context; if so, then reject Drop impl as specialized. 4. Otherwise, unification succeeded without leaking skolemized variables: accept the Drop impl. We identify whether a Drop impl is injecting new predicates by simply looking whether the predicate, after an appropriate substitution, appears on the struct/enum definition.
2015-03-24correct reference wrt shiftsSteve Klabnik-3/+3
Fixes #23421
2015-03-24Add basic information about associated typesSteve Klabnik-0/+203
2015-03-23Improve the wording of the example section description on the ownership pageLiam Monahan-2/+2
to make it more clear.
2015-03-23rollup merge of #23645: steveklabnik/gh23642Alex Crichton-6/+3
Fixes #23642
2015-03-23Test fixes and rebase conflicts, round 2Alex Crichton-1/+2
2015-03-23rollup merge of #23598: brson/gateAlex Crichton-11/+50
Conflicts: src/compiletest/compiletest.rs src/libcollections/lib.rs src/librustc_back/lib.rs src/libserialize/lib.rs src/libstd/lib.rs src/libtest/lib.rs src/test/run-make/rustdoc-default-impl/foo.rs src/test/run-pass/env-home-dir.rs
2015-03-23rollup merge of #23639: steveklabnik/gh21305Alex Crichton-2/+31
Fixes #21305 Not sure if we should include more than this here, but it should be good to have at least this.
2015-03-23rollup merge of #23619: steveklabnik/gh23220Alex Crichton-10/+10
Fixes #23571 I _think_ this is better, but other suggestions welcome too.
2015-03-23rollup merge of #23618: steveklabnik/gh23571Alex Crichton-0/+35
Fixes #23571
2015-03-23rollup merge of #23401: tshepang/crates-and-modules-doc-nitsAlex Crichton-73/+21
Conflicts: src/doc/trpl/crates-and-modules.md
2015-03-23rollup merge of #22954: ches/docsAlex Crichton-42/+48
Greetings Rustaceans! I've just been getting acquainted with Rust through the guide. First let me say that it's already in great shape, chapters are kept a good length to be digestible and paced to move the reader along fluidly, so my compliments to contributors! Along the way I noticed a few minor copy errors, and also a few areas that I thought more subjectively could stand to be improved. My commits here are divided so that minor edits unlikely to be very contentious could be cherry-picked, and then topically on parts that might generate more discussion. I also have some comments and questions that aren't directly associated with any changes on this branch yet. I'm not sure how you like to triage this sort of thing but I'll present them below and if it's appropriate they could be moved to separate issues or I might be able to help work some of them out within the scope of this PR. Sorry that these are a lot to take in, pretty much everything below here can be digested independently of the current changes in this PR so you could read the rest later :smile: ### Questions and Comments I'll give stable links to doc revisions as of this writing. 1. The [example using `PartialEq` in the Traits chapter][1] is poor—we have no idea how `PartialEq` works at this point in the text (or at any point, AFAICT), so it isn't clear why it won't work as a trait bound in this situation and `Float` almost magically does, with the aid of existing tailor-made identity functions that seem unlikely to be so conveniently available when we encounter a scenario like this in our real-world code. This section just seems glossed over, or perhaps content has moved around over time or there's an assumption that implementing equality with `PartialEq` should be covered in the guide eventually so this example will be less foreign. As it stands the text is hard to follow and not very meaningful. 2. I found treatment of the relationship of trait objects to pointers in the *Static and Dynamic Dispatch* chapter unclear. [The "Why Pointers?" section][2] opens with this line: > The use of language like "fat pointer" implies that a trait object is always a pointer of some form, but why? But the phrase "fat pointer" hasn't been used anywhere before. This is some of the more complex material in the guide, but this section nevertheless feels displaced, not clearly connecting preceding subject matter. Earlier we've covered the internal representation of trait objects and significance of pointers they contain, but it hasn't been spelled out (other than what `&Foo` syntax suggests) that trait objects are references (and why). That's what the "Why Pointers?" section is aiming to do I gather, but it seems out of place, I think it'd make more sense to cover this before the gory details of their internals. 3. Suggestion: move the *Error Handling* chapter much earlier in the Intermediate section of the guide, or even into the Basics section. I know the Intermediate section isn't intended to be read in order per se, but plenty of people like me are just going to read it straight through anyway :grin: These are pretty fundamental concepts to understand and `Option`, `Result`, and idioms like `unwrap()` and `.ok().expect()` are referenced numerous times throughout the rest of the guide. They feature pretty prominently as early as *Standard Input* and *Guessing Game* chapters in Basics, in fact. I happen to have a good understanding of these already through encountering their analogs in typed functional languages, but if I didn't I believe I really would have appreciated reading *Error Handling* much earlier. 4. In the `rustdoc` chapter, a [comment at the beginning of the first source example][3] refers to a "link" crate attribute being needed. There seems to be no such attribute present in the source. I believe this refers to `crate_type` [according to the reference][4], but it'd be nice if this example were updated/clarified (I think `crate_id` is deprecated/obsolete too). This brings me to a related comment also: after encountering crate attributes in the reference and also docs on Cargo configuration like `crate-type = ["dylib"]`, I'm uncertain about the relationship/redundancy between these. I'm sure this is the kind of thing where docs are simply struggling to keep pace with rapid changes in Rust and Cargo, just wanted to flag that this distinction ought to be clearly covered in the docs for one or the other at some point, it's presently hard to track down. 5. Minor: link to sample editor configurations in [the introductory chapter][5] is broken, probably the generator automatically translates `.md` links to `.html`. Perhaps it shouldn't do that for absolute URLs. 6. Following from my changes to the enums coverage in [*Compound Data Types*][6] in this PR: sum types are an important topic and I tried to make some improvements, but I think the motivating example of `Character` with `Digit(i32)` and `Other` variants is a pretty weak one, and a better example could greatly improve cohesion with the `Ordering` coverage later in the section and how that ties into pattern matching in the subsequent chapter. I just haven't thought of a better example to suggest yet. In particular, the text states: > This may seem rather limiting, but it's a limitation which we can overcome. This is referring to `Character`, and actually to more than one limitation: the preceding admonition that its variants aren't comparable/don't have ordering, and don't support binary operators like `*` and `+`. Overcoming these limitations actually never gets explained—we next cover how `Ordering` works as an enum itself for plain `i32`s, but never get around to showing how this might be applied to our `Digit` variant type. Since the coverage of enums already segues into pattern matching and this could be even tighter with a stronger example, it might be nice if our example enum were somehow connected to the final example program for the Basics section too, where `Ordering` reappears. I don't see how it would fit with the current guessing game example, but food for thought. 7. `#[derive]` seems conspicuously missing from the guide. It would probably make sense to introduce after showing simple examples of implementing equality and/or ordering traits by hand, which have been mentioned as possibilities above. Perhaps it's too much to breach this as early as the Basic section though without traits being introduced. `#[derive]` itself and the derivable traits can certainly be saved for Intermediate and referenced as covered later, in any case. r? @steveklabnik for docs. [1]: https://github.com/rust-lang/rust/blob/157614249594f187f421cd97f928e64c5ab5c1fa/src/doc/trpl/traits.md#our-inverse-example [2]: https://github.com/rust-lang/rust/blob/157614249594f187f421cd97f928e64c5ab5c1fa/src/doc/trpl/static-and-dynamic-dispatch.md#why-pointers [3]: https://github.com/rust-lang/rust/blob/157614249594f187f421cd97f928e64c5ab5c1fa/src/doc/trpl/documentation.md#creating-documentation [4]: http://doc.rust-lang.org/reference.html#linkage [5]: https://github.com/rust-lang/rust/blob/157614249594f187f421cd97f928e64c5ab5c1fa/src/doc/trpl/hello-world.md [6]: https://github.com/rust-lang/rust/blob/157614249594f187f421cd97f928e64c5ab5c1fa/src/doc/trpl/compound-data-types.md#enums
2015-03-23Add #![feature] attributes to doctestsBrian Anderson-3/+39
2015-03-23rustdoc: interpret all leading feature attributes in examples as crate ↵Brian Anderson-8/+11
attributes This makes it possible to write `#![feature(foo)]` in doc tests.
2015-03-23Make note of str in 'more strings' chapterSteve Klabnik-2/+31
Fixes #21035
2015-03-23Don't conflate regions and affine typesSteve Klabnik-6/+3
Fixes #23642
2015-03-23Fix a typo in the Rust Book ownership page.Liam Monahan-2/+2
2015-03-23Rollup merge of #23590 - FuGangqiang:attr, r=alexcrichtonManish Goregaokar-3/+3
2015-03-23add lifetime for `while` and `for` expressionFuGangqiang-2/+2
2015-03-23fix the attributes sytaxFuGangqiang-1/+1
2015-03-22book: some Crates and Modules nitsTshepang Lekhonkhobe-76/+24
2015-03-22Re-word explanation on closures in introSteve Klabnik-10/+10
Fixes #23571
2015-03-22Document how to document macrosSteve Klabnik-0/+35
Fixes #23571
2015-03-21guide: Improvements to language covering enumsChes Martin-33/+35
2015-03-21guide: minor copy editsChes Martin-10/+14
2015-03-20Remove manual numbers from TRPLSteve Klabnik-3/+3
Rustbook already does this.
2015-03-20Auto merge of #23537 - steveklabnik:gh22551, r=alexcrichtonbors-3/+28
Fixes #22551 ('grammar' wasn't really used in the chapter at all)
2015-03-20Add AST to the glossarySteve Klabnik-3/+28
Fixes #22551
2015-03-20Auto merge of #23522 - steveklabnik:gh22518, r=Manishearthbors-894/+0
When investigating #22518, this chapter is really the only part that has `rand`, and the rest still works without it. We should have some examples like this, but for now, it's more important to be right than perfect.
2015-03-20Rollup merge of #23532 - steveklabnik:gh22002, r=alexcrichtonManish Goregaokar-0/+2
Fixes #22002
2015-03-20Rollup merge of #23447 - kjpgit:kjp/pointerexample, r=steveklabnikManish Goregaokar-13/+15
These two borrowing examples were confusing/misleading. This changes it to more clearly show how you _can_ borrow a box, and also uses & instead of &*.
2015-03-19Reference Drop in FFI chapterSteve Klabnik-0/+2
Fixes #22002
2015-03-19Remove incorrect statement about raw pointers.Steve Klabnik-4/+0
Fixes #21709
2015-03-19Remove the Guessing Game from the bookSteve Klabnik-894/+0
Fixes #22518
2015-03-19Rollup merge of #23497 - steveklabnik:gh21589, r=alexcrichtonManish Goregaokar-0/+5
Fixes #21589
2015-03-19Note ::foo::bar() in the crates guideSteve Klabnik-0/+5
Fixes #21589
2015-03-19Rename should_fail to should_panic in docsJohannes Oertel-9/+9
2015-03-17book: improve pointer box borrowing exampleskjpgit-13/+15
These two borrowing examples were confusing/misleading. This changes it to more clearly show how you _can_ borrow a box, and also uses & instead of &*.
2015-03-17Rollup merge of #23385 - tamird:cleanup-whitespace, r=alexcrichtonManish Goregaokar-66/+63
r? @alexcrichton Conflicts: src/test/run-pass/test-fn-signature-verification-for-explicit-return-type.rs
2015-03-17Rollup merge of #23417 - padenot:patch-1, r=steveklabnikManish Goregaokar-1/+1
This looks like the most logical target to give to this link, or at least what I would expect as someone that want to integrate with a native library. r? @steveklabnik
2015-03-16Fix 404 to crates.io's doc on integrating with a native toolchainPaul ADENOT-1/+1
This looks like the most logical target to give to this link, or at least what I would expect as someone that want to integrate with a native library. r? @steveklabnik
2015-03-16Fallout in testing.Nick Cameron-3/+5
2015-03-15Strip trailing whitespaceTamir Duberstein-63/+63
2015-03-15Strip all leading/trailing newlinesTamir Duberstein-3/+0
2015-03-15Rollup merge of #23368 - EduardoBautista:fix-closures-chapter, r=steveklabnikManish Goregaokar-1/+1
"body": null,
2015-03-15Rollup merge of #23367 - EduardoBautista:fix-indentation-in-book, r=steveklabnikManish Goregaokar-4/+4
It was using tabs.