]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #12774 : alexcrichton/rust/proc-bounds, r=pcwalton
bors [Wed, 12 Mar 2014 03:51:56 +0000 (20:51 -0700)]
auto merge of #12774 : alexcrichton/rust/proc-bounds, r=pcwalton

This is needed to make progress on #10296 as the default bounds will no longer
include Send. I believe that this was the originally intended syntax for procs,
and it just hasn't been necessary up until now.

10 years agoauto merge of #12650 : huonw/rust/librand, r=alexcrichton
bors [Wed, 12 Mar 2014 02:31:57 +0000 (19:31 -0700)]
auto merge of #12650 : huonw/rust/librand, r=alexcrichton

Move std::rand to a separate rand crate

This functionality is not super-core and so doesn't need to be included
in std. It's possible that std may need rand (it does a little bit now,
for io::test) in which case the functionality required could be moved to
a secret hidden module and reexposed by librand.

Unfortunately, using #[deprecated] here is hard: there's too much to
mock to make it feasible, since we have to ensure that programs still
typecheck to reach the linting phase.

Also, deprecates/removes `rand::rng` (this time using `#[deprecated]`), since it's too easy to accidentally use inside a loop, making things very slow (have to read randomness from the OS and seed the RNG each time.)

10 years agosyntax: Add support for trait bounds on procs
Alex Crichton [Sun, 9 Mar 2014 02:21:01 +0000 (18:21 -0800)]
syntax: Add support for trait bounds on procs

This is needed to make progress on #10296 as the default bounds will no longer
include Send. I believe that this was the originally intended syntax for procs,
and it just hasn't been necessary up until now.

10 years agorand: deprecate `rng`.
Huon Wilson [Sun, 2 Mar 2014 01:59:35 +0000 (12:59 +1100)]
rand: deprecate `rng`.

This should be called far less than it is because it does expensive OS
interactions and seeding of the internal RNG, `task_rng` amortises this
cost. The main problem is the name is so short and suggestive.

The direct equivalent is `StdRng::new`, which does precisely the same
thing.

The deprecation will make migrating away from the function easier.

10 years agoUpdate users for the std::rand -> librand move.
Huon Wilson [Sun, 2 Mar 2014 00:33:24 +0000 (11:33 +1100)]
Update users for the std::rand -> librand move.

10 years agoRemove the dependence of std::io::test on rand.
Huon Wilson [Sat, 1 Mar 2014 13:36:33 +0000 (00:36 +1100)]
Remove the dependence of std::io::test on rand.

This replaces it with a manual "task rng" using XorShift and a crappy
seeding mechanism. Theoretically good enough for the purposes
though (unique for tests).

10 years agostd: Move rand to librand.
Huon Wilson [Sun, 2 Mar 2014 00:23:04 +0000 (11:23 +1100)]
std: Move rand to librand.

This functionality is not super-core and so doesn't need to be included
in std. It's possible that std may need rand (it does a little bit now,
for io::test) in which case the functionality required could be moved to
a secret hidden module and reexposed by librand.

Unfortunately, using #[deprecated] here is hard: there's too much to
mock to make it feasible, since we have to ensure that programs still
typecheck to reach the linting phase.

10 years agoauto merge of #12783 : adrientetar/rust/more-docs, r=alexcrichton
bors [Tue, 11 Mar 2014 19:36:58 +0000 (12:36 -0700)]
auto merge of #12783 : adrientetar/rust/more-docs, r=alexcrichton

- remove `node.js` dep., it has no effect as of #12747 (1)
- switch between LaTeX compilers, some cleanups
- CSS: fixup the print stylesheet, refactor highlighting code (2)

(1): `prep.js` outputs its own HTML directives, which `pandoc` cannot recognize when converting the document into LaTeX (this is why the PDF docs have never been highlighted as of now).

Note that if we were to add the `.rust` class to snippets, we could probably use pandoc's native highlighting capatibilities i.e. Kate ([here is](http://adrientetar.github.io/rust-tuts/tutorial/tutorial.pdf) an example of that).

(2): the only real highlighting change is for lifetimes which are now brown instead of red, the rest is just refactor of twos shades of red that look the same.
Also I made numbers highlighting for src in rustdoc a tint more clear so that it is less bothering.

@alexcrichton, @huonw

Closes #9873. Closes #12788.

10 years agoauto merge of #12780 : zslayton/rust/json-nav, r=alexcrichton
bors [Tue, 11 Mar 2014 18:17:01 +0000 (11:17 -0700)]
auto merge of #12780 : zslayton/rust/json-nav, r=alexcrichton

This is my first non-docs contribution to Rust, so please let me know what I can fix. I probably should've submitted this to the mailing list first for comments, but it didn't take too long to implement so I figured I'd just give it a shot.

These changes are modeled loosely on the [JsonNode API](http://jackson.codehaus.org/1.7.9/javadoc/org/codehaus/jackson/JsonNode.html) provided by the [Jackson JSON processor](http://jackson.codehaus.org/).

Many common use cases for parsing JSON involve pulling one or more fields out of an object, however deeply nested. At present, this requires writing a pyramid of match statements. The added methods in this PR aim to make this a more painless process.

**Edited to reflect final implementation**

Example JSON:
```json
{
    "successful" : true,
    "status" : 200,
    "error" : null,
    "content" : {
        "vehicles" : [
            {"make" : "Toyota", "model" : "Camry", "year" : 1997},
            {"make" : "Honda", "model" : "Accord", "year" : 2003}
        ]
    }
}
```

Accessing "successful":
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let was_successful: Option<bool> = example_json.find(&~"successful").and_then(|j| j.as_boolean());
```

Accessing "status":
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let status_code : Option<f64> = example_json.find(&~"status").and_then(|j| j.as_number());
```

Accessing "vehicles":
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let vehicle_list: Option<List> = example_json.search(&~"vehicles").and_then(|j| j.as_list());
```

Accessing "vehicles" with an explicit path:
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let vehicle_list: Option<List> = example_json.find_path(&[&~"content", &~"vehicles"]).and_then(|j| j.as_list());
```

Accessing "error", which might be null or a string:
```rust
 let example_json : Json = from_str("...above json...").unwrap();
 let error: Option<Json> = example_json.find(&~"error");
 if error.is_null() { // This would be nicer as a match, I'm just illustrating the boolean test methods
    println!("Error is null, everything's fine.");
 } else if error.is_str(){
    println!("Something went wrong: {}", error.as_string().unwrap());
}
```

Some notes:
* Macros would help to eliminate some of the repetitiveness of the implementation, but I couldn't use them due to #4621. (**Edit**: There is no longer repetitive impl. Methods were simplified to make them more composable.)
* Would it be better to name methods after the Json enum type (e.g. `get_string`) or the associated Rust built-in? (e.g. `get_str`)
* TreeMap requires its keys to be &~str. Because of this, all of the new methods required &~str for their parameters. I'm uncertain what the best approach to fixing this is: neither demanding an owned pointer nor allocating within the methods to appease TreeMap's find() seems desirable. If I were able to take &str, people could put together paths easily with `"foo.bar.baz".split('.').collect();` (**Edit**: Follow on investigation into making TreeMap able to search by Equiv would be worthwhile.)
* At the moment, the `find_<sometype>` methods all find the first match for the provided key and attempt to return that value if it's of the specified type. This makes sense to me, but it's possible that users would interpret a call to `find_boolean("successful")` as looking for the first "successful" item that was a boolean rather than looking for the first "successful" and returning None if it isn't boolean. (**Edit**: No longer relevant.)

I hope this is helpful. Any feedback is appreciated!

10 years agoauto merge of #12556 : alexcrichton/rust/weak-linkage, r=brson
bors [Tue, 11 Mar 2014 16:56:57 +0000 (09:56 -0700)]
auto merge of #12556 : alexcrichton/rust/weak-linkage, r=brson

It is often convenient to have forms of weak linkage or other various types of
linkage. Sadly, just using these flavors of linkage are not compatible with
Rust's typesystem and how it considers some pointers to be non-null.

As a compromise, this commit adds support for weak linkage to external symbols,
but it requires that this is only placed on extern statics of type `*T`.
Codegen-wise, we get translations like:

```rust
    // rust code
    extern {
        #[linkage = "extern_weak"]
        static foo: *i32;
    }

    // generated IR
    @foo = extern_weak global i32
    @_some_internal_symbol = internal global *i32 @foo
```

All references to the rust value of `foo` then reference `_some_internal_symbol`
instead of the symbol `_foo` itself. This allows us to guarantee that the
address of `foo` will never be null while the value may sometimes be null.

An example was implemented in `std::rt::thread` to determine if
`__pthread_get_minstack()` is available at runtime, and a test is checked in to
use it for a static value as well. Function pointers a little odd because you
still need to transmute the pointer value to a function pointer, but it's
thankfully better than not having this capability at all.

Thanks to @bnoordhuis for the original patch, most of this work is still his!

10 years agodoc: remove outdated tutorial entry, restore removed Makefile entries
Adrien Tétar [Sun, 9 Mar 2014 12:52:16 +0000 (13:52 +0100)]
doc: remove outdated tutorial entry, restore removed Makefile entries

10 years agodoc: auto-generate LaTeX includes
Adrien Tétar [Sun, 9 Mar 2014 11:41:27 +0000 (12:41 +0100)]
doc: auto-generate LaTeX includes

10 years agoAdded convenience methods and accompanying tests to the Json class.
zslayton [Sun, 9 Mar 2014 06:30:27 +0000 (01:30 -0500)]
Added convenience methods and accompanying tests to the Json class.

Fixed some styling issues with trailing whitespace.

- Removed redundant functions.
- Renamed `get` to `find`
- Renamed `get_path` to `find_path`
- Renamed `find` to `search`
- Changed as_object and as_list to return Object and List
  rather than the underlying implementation types
  of TreeMap<~str,Json> and ~[Json]
- Refactored find_path to use a fold() instead of recursion

Formatting fixes.

Fixed spacing, deleted comment.

Added convenience methods and accompanying tests to the Json class.

Updated tests to expect less pointer indirection.

10 years agorustc: Support various flavors of linkages
Alex Crichton [Wed, 26 Feb 2014 00:15:10 +0000 (16:15 -0800)]
rustc: Support various flavors of linkages

It is often convenient to have forms of weak linkage or other various types of
linkage. Sadly, just using these flavors of linkage are not compatible with
Rust's typesystem and how it considers some pointers to be non-null.

As a compromise, this commit adds support for weak linkage to external symbols,
but it requires that this is only placed on extern statics of type `*T`.
Codegen-wise, we get translations like:

    // rust code
    extern {
        #[linkage = "extern_weak"]
        static foo: *i32;
    }

    // generated IR
    @foo = extern_weak global i32
    @_some_internal_symbol = internal global *i32 @foo

All references to the rust value of `foo` then reference `_some_internal_symbol`
instead of the symbol `_foo` itself. This allows us to guarantee that the
address of `foo` will never be null while the value may sometimes be null.

An example was implemented in `std::rt::thread` to determine if
`__pthread_get_minstack()` is available at runtime, and a test is checked in to
use it for a static value as well. Function pointers a little odd because you
still need to transmute the pointer value to a function pointer, but it's
thankfully better than not having this capability at all.

10 years agoauto merge of #12765 : TeXitoi/rust/fix-shootout-reverse-complement, r=alexcrichton
bors [Tue, 11 Mar 2014 08:51:59 +0000 (01:51 -0700)]
auto merge of #12765 : TeXitoi/rust/fix-shootout-reverse-complement, r=alexcrichton

10 years agofix a bug in shootout-reverse-complement, official tests should pass with it
Guillaume Pinot [Sat, 8 Mar 2014 15:56:07 +0000 (16:56 +0100)]
fix a bug in shootout-reverse-complement, official tests should pass with it

In the "reverse-complement" loop, if there is an odd number of element,
we forget to complement the element in the middle.  For example, if the
input is "ggg", the result before the fix is "CgC" instead of "CCC".

This is because of this bug that the official shootout says that the rust
version is in "Bad Output".  This commit should fix this error.

10 years agoauto merge of #12617 : sfackler/rust/item-modifier, r=alexcrichton
bors [Tue, 11 Mar 2014 07:32:04 +0000 (00:32 -0700)]
auto merge of #12617 : sfackler/rust/item-modifier, r=alexcrichton

Where ItemDecorator creates new items given a single item, ItemModifier
alters the tagged item in place. The expansion rules for this are a bit
weird, but I think are the most reasonable option available.

When an item is expanded, all ItemModifier attributes are stripped from
it and the item is folded through all ItemModifiers. At that point, the
process repeats until there are no ItemModifiers in the new item.

cc @huonw

10 years agoAdd an ItemModifier syntax extension type
Steven Fackler [Fri, 28 Feb 2014 07:49:25 +0000 (23:49 -0800)]
Add an ItemModifier syntax extension type

Where ItemDecorator creates new items given a single item, ItemModifier
alters the tagged item in place. The expansion rules for this are a bit
weird, but I think are the most reasonable option available.

When an item is expanded, all ItemModifier attributes are stripped from
it and the item is folded through all ItemModifiers. At that point, the
process repeats until there are no ItemModifiers in the new item.

10 years agoauto merge of #12793 : brson/rust/installer, r=alexcrichton
bors [Tue, 11 Mar 2014 05:42:02 +0000 (22:42 -0700)]
auto merge of #12793 : brson/rust/installer, r=alexcrichton

Work towards #9876.

Several minor things here:
  * Fix the `need_ok` function in `configure`
  * Install man pages with non-executable permissions
  * Use the correct directory for man pages when installing (this was a recent regression)
  * Put all distributables in a new `dist/` directory in the build directory (there are soon to be significantly more of these)

Finally, this also creates a new, more precise way to install and uninstall Rust's files, the `install.sh` script, and creates a build target (currently `dist-tar-bins`) that creates a binary tarball containing all the installable files, boilerplate and license docs, and `install.sh`.

This binary tarball is the lowest-common denominator way to install Rust on Unix. We'll use it as the default installer on Linux (OS X will use .pkg).

## How `install.sh` works

* First, the makefiles (`prepare.mk` and `dist.mk`) put all the stuff that needs to be installed in a new directory in `dist/`.
* Then it puts `install.sh` in that same directory and a list of all the files to install at `rustlib/manifest`.
* Then the directory can be packaged and distributed.
* When `install.sh` runs it does some sanity checking then copies everything in the manifest to the install prefix, then copies the manifest as well.
* When `install.sh` runs again in the future it first looks for the existing manifest at the install prefix, and if it exists deletes everything in it. This is how the core distribution is upgraded - cargo is responsible for the rest.
* `install.sh --uninstall` will uninstall Rust

## Future work:

  * Modify `install.sh` to accept `--man-dir` etc
  * Rewrite `install.mk` to delegate to `install.sh`
  * Investigate how `install.sh` does or doesn't work with .pkg on Mac
  * Modify `dist.mk` to create `.pkg` files for all hosts
  * Possibly use [makeself](http://www.megastep.org/makeself/) to create self-extracting installers
  * Modify dist-snap bots run on mac as well, uploading binary tarballs and .pkg files for the four combos of linux, mac, x86, and x86_64.
  * Adjust build system to be able to augment versions with '-nightly'
  * Adjust build system to name dist artifacts without version numbers e.g. `rust-nightly-...pkg`. This is so we don't leave a huge trail of old nightly binaries on S3 - they just get overwritten.
  * Create new dist-nightly builder
  * Give the build master a new cron job to push to dist-nightly every night
  * Add docs to distributables
  * Update README.md to reflect the new reality
  * Modernize the website to promote new installers

10 years agoauto merge of #12766 : TeXitoi/rust/fix-shootout-spectralnorm, r=alexcrichton
bors [Tue, 11 Mar 2014 03:07:02 +0000 (20:07 -0700)]
auto merge of #12766 : TeXitoi/rust/fix-shootout-spectralnorm, r=alexcrichton

10 years agoauto merge of #12652 : rcxdude/rust/hexfloatext, r=alexcrichton
bors [Tue, 11 Mar 2014 01:52:03 +0000 (18:52 -0700)]
auto merge of #12652 : rcxdude/rust/hexfloatext, r=alexcrichton

Closes #1433. Implemented after suggestion by @cmr in #12323

This is slightly less flexible than the implementation in #12323 (binary and octal floats aren't supported, nor are underscores in the literal), but is cleaner in that it doesn't modify the core grammar, or require odd syntax for the number itself. The missing features could be added back with relatively little effort (the main awkwardness is parsing the string. Is there a good approach for this in the stdlib currently?)

10 years agoImplement hexadecimal floating point literals via a syntax extension
Douglas Young [Sun, 2 Mar 2014 18:41:17 +0000 (18:41 +0000)]
Implement hexadecimal floating point literals via a syntax extension

closes #1433

10 years agoauto merge of #12733 : edwardw/rust/rw-liveness, r=nikomatsakis
bors [Mon, 10 Mar 2014 20:42:05 +0000 (13:42 -0700)]
auto merge of #12733 : edwardw/rust/rw-liveness, r=nikomatsakis

- Repurposes `MoveData.assignee_ids` to mean only `=` but not `+=`, so
  that borrowck effectively classifies all expressions into assignees,
  uses or both.
- Removes two `span_err` in liveness analysis, which are now borrowck's
  responsibilities.

Closes #12527.

10 years agoauto merge of #12670 : dmski/rust/master, r=nick29581
bors [Mon, 10 Mar 2014 19:27:05 +0000 (12:27 -0700)]
auto merge of #12670 : dmski/rust/master, r=nick29581

CodeMap.span_to_* perform a lookup of a BytePos(sp.hi), which lands into the next filemap if the last byte of range denoted by Span is also the last byte of the filemap, which results in ICEs or incorrect error reports.

        Example:
            ````

            pub fn main() {
                let mut num = 3;
                let refe = &mut num;
                *refe = 5;
                println!("{}", num);
            }````

(note the empty line in the beginning and the absence of newline at the end)

The above would have caused ICE when trying to report where "refe" borrow ends.
The above without an empty line in the beginning would have reported borrow end to be the first line.

Most probably, this is also responsible for (at least some occurrences of) issue #8256.

The issue is fixed by always adding a newline at the end of non-empty filemaps in case there isn't a new line there already.

10 years agosyntax: fixed ICEs and incorrect line nums when reporting Spans at the end of the...
Dmitry Promsky [Mon, 3 Mar 2014 10:44:43 +0000 (14:44 +0400)]
syntax: fixed ICEs and incorrect line nums when reporting Spans at the end of the file.

CodeMap.span_to_* perform a lookup of a BytePos(sp.hi), which lands into the next filemap if the last byte of range denoted by Span is also the last byte of the filemap, which results in ICEs or incorrect error reports.

    Example:
        ````

        pub fn main() {
            let mut num = 3;
            let refe = &mut num;
            *refe = 5;
            println!("{}", num);
        }````

(note the empty line in the beginning and the absence of newline at the end)

The above would have caused ICE when trying to report where "refe" borrow ends.
The above without an empty line in the beginning would have reported borrow end to be the first line.

Most probably, this is also responsible for (at least some occurrences of) issue #8256.

The issue is fixed by always adding a newline at the end of non-empty filemaps in case there isn't a new line there already.

10 years agoinstall.sh: untabify
Brian Anderson [Sun, 9 Mar 2014 21:56:37 +0000 (14:56 -0700)]
install.sh: untabify

10 years agoinstall.sh: Improve error handling
Brian Anderson [Sun, 9 Mar 2014 21:16:41 +0000 (14:16 -0700)]
install.sh: Improve error handling

10 years agomk: Put all distribution artifacts in dist/
Brian Anderson [Sun, 9 Mar 2014 21:15:33 +0000 (14:15 -0700)]
mk: Put all distribution artifacts in dist/

Also, add license docs to installers

10 years agomk: forcibly delete dest dir when PREPARE_CLEAN
Brian Anderson [Sun, 9 Mar 2014 21:14:34 +0000 (14:14 -0700)]
mk: forcibly delete dest dir when PREPARE_CLEAN

10 years agomk: Tweak the status messages for prepare.mk to say 'prepare', not 'install'
Brian Anderson [Sun, 9 Mar 2014 21:13:48 +0000 (14:13 -0700)]
mk: Tweak the status messages for prepare.mk to say 'prepare', not 'install'

10 years agomk: Use the correct permissions for man pages
Brian Anderson [Sun, 9 Mar 2014 21:12:11 +0000 (14:12 -0700)]
mk: Use the correct permissions for man pages

10 years agoAdd /dist/ to .gitignore
Brian Anderson [Sun, 9 Mar 2014 21:11:24 +0000 (14:11 -0700)]
Add /dist/ to .gitignore

10 years agoconfigure: Create the dist directory
Brian Anderson [Sun, 9 Mar 2014 21:10:42 +0000 (14:10 -0700)]
configure: Create the dist directory

10 years agomk: dist-installer builds a binary installer
Brian Anderson [Sun, 2 Mar 2014 05:38:13 +0000 (21:38 -0800)]
mk: dist-installer builds a binary installer

10 years agomk: Optionally clean the destination when preparing install image
Brian Anderson [Sun, 2 Mar 2014 05:39:55 +0000 (21:39 -0800)]
mk: Optionally clean the destination when preparing install image

10 years agomk: Put man pages in correct directory
Brian Anderson [Sun, 2 Mar 2014 05:39:36 +0000 (21:39 -0800)]
mk: Put man pages in correct directory

10 years agoBugfixes and cleanup to configure script
Brian Anderson [Sun, 2 Mar 2014 05:39:05 +0000 (21:39 -0800)]
Bugfixes and cleanup to configure script

10 years agodoc: CSS fixes
Adrien Tétar [Sun, 9 Mar 2014 11:29:25 +0000 (12:29 +0100)]
doc: CSS fixes

- fixup and refactor highlighting code
- have a proper print stylesheet

10 years agodoc: have a real switch b/w LaTeX compilers
Adrien Tétar [Sun, 9 Mar 2014 10:21:05 +0000 (11:21 +0100)]
doc: have a real switch b/w LaTeX compilers

10 years agoborrowck: classify expressions as assignees, uses or both
Edward Wang [Thu, 6 Mar 2014 14:58:34 +0000 (22:58 +0800)]
borrowck: classify expressions as assignees, uses or both

- Repurposes `MoveData.assignee_ids` to mean only `=` but not `+=`, so
  that borrowck effectively classifies all expressions into assignees,
  uses or both.
- Removes two `span_err` in liveness analysis, which are now borrowck's
  responsibilities.

Closes #12527.

10 years agofix shootout-spectralnorm, broken since Arc cannot unwrap.
Guillaume Pinot [Sat, 8 Mar 2014 16:04:57 +0000 (17:04 +0100)]
fix shootout-spectralnorm, broken since Arc cannot unwrap.

10 years agodoc: remove node.js dependency
Adrien Tétar [Sun, 9 Mar 2014 10:06:03 +0000 (11:06 +0100)]
doc: remove node.js dependency

`prep.js` outputs its own HTML directives, which `pandoc` cannot
recognize when converting the document into LaTeX (this is why the
PDF docs have never been highlighted as of now).

Note that if we were to add the `.rust` class to snippets, we could
probably use pandoc's native highlighting capatibilities i.e. Kate.

10 years agoauto merge of #12747 : huonw/rust/rustdoc-markdown, r=alexcrichton
bors [Sun, 9 Mar 2014 10:06:42 +0000 (03:06 -0700)]
auto merge of #12747 : huonw/rust/rustdoc-markdown, r=alexcrichton

This gives Rustdoc the ability to render our guides, tutorial and manual and modifies the those documents (minor modifications) and makefiles to achieve this.

See commits for more details (especially the makefile rewrite).

10 years agomk: only build PDFs of the manual and tutorial.
Huon Wilson [Sun, 9 Mar 2014 04:54:16 +0000 (15:54 +1100)]
mk: only build PDFs of the manual and tutorial.

This restores the old behaviour (as compared to building PDF versions of
all standalone docs), because some of the guides use unicode characters,
which seems to make pdftex unhappy.

10 years agodocs: render rustdoc docs with rustdoc, hack around sundown code-fence
Huon Wilson [Sun, 9 Mar 2014 03:14:07 +0000 (14:14 +1100)]
docs: render rustdoc docs with rustdoc, hack around sundown code-fence
parsing limitations.

Sundown parses

    ```
    ~~~

as a valid codeblock (i.e. mismatching delimiters), which made using
rustdoc on its own documentation impossible (since it used nested
codeblocks to demonstrate how testable codesnippets worked).

This modifies those snippets so that they're delimited by indentation,
but this then means they're tested by `rustdoc --test` & rendered as
Rust code (because there's no way to add `notrust` to
indentation-delimited code blocks). A comment is added to stop the
compiler reading the text too closely, but this unfortunately has to be
visible in the final docs, since that's the text on which the
highlighting happens.

10 years agotutorial: hack a code snippet to make it compile.
Huon Wilson [Sun, 9 Mar 2014 01:50:45 +0000 (12:50 +1100)]
tutorial: hack a code snippet to make it compile.

This is meant to be compiling a crate, but the crate_id attribute seems
to be upsetting it if the attribute is actually on the crate. I.e. this
makes this test compile by putting the crate_id attribute on a function
and so it's ignored. Such a hack. :(

10 years agomk: rename `check-...-doc-<crate>` to `check-...-doc-crate-<crate>`.
Huon Wilson [Sun, 9 Mar 2014 03:55:20 +0000 (14:55 +1100)]
mk: rename `check-...-doc-<crate>` to `check-...-doc-crate-<crate>`.

E.g. this stops check-...-doc rules for `rustdoc.md` and `librustdoc`
from stamping on each other, so that they are correctly built and
tested. (Previously only the rustdoc crate was tested.)

10 years agomk: rewrite the documentation handling.
Huon Wilson [Sat, 8 Mar 2014 14:41:31 +0000 (01:41 +1100)]
mk: rewrite the documentation handling.

This converts it to be very similar to crates.mk, with a single list of
the documentation items creating all the necessary bits and pieces.

Changes include:
- rustdoc is used to render HTML & test standalone docs
- documentation building now obeys NO_REBUILD=1
- testing standalone docs now obeys NO_REBUILD=1
- L10N is slightly less broken (in particular, it shares dependencies
  and code with the rest of the code)
- PDFs can be built for all documentation items, not just tutorial and
  manual
- removes the obsolete & unused extract-tests.py script
- adjust the CSS for standalone docs to use the rustdoc syntax
  highlighting

10 years agodocs: adjust code blocks to pass with rustdoc.
Huon Wilson [Sat, 8 Mar 2014 11:05:20 +0000 (22:05 +1100)]
docs: adjust code blocks to pass with rustdoc.

The changes are basically just because rustdoc runs tests/rendering on
more snippets by default (i.e. everything without a `notrust` tag), and
not anything significant.

10 years agorustdoc: adding some common feature gates when testing a markdown file.
Huon Wilson [Sat, 8 Mar 2014 10:30:43 +0000 (21:30 +1100)]
rustdoc: adding some common feature gates when testing a markdown file.

The manual, tutorial and guides need the feature gates quite often,
unfortunately, so this is the low-cost path to migrating to use
rustdoc. This is only activated for pure-Markdown files.

Preferably this would be avoided: #12773

10 years agorustdoc: hardcode each header as a link.
Huon Wilson [Fri, 7 Mar 2014 14:24:54 +0000 (01:24 +1100)]
rustdoc: hardcode each header as a link.

This avoids having to include JS in the guide/tutorial/manual pages just
to get the headers being links. The on-hover behaviour showing the
little section marker § is preserved, because that gives a useful hint
that the heading is a link.

10 years agorustdoc: add table-of-contents recording & rendering, use it with plain
Huon Wilson [Fri, 7 Mar 2014 14:13:17 +0000 (01:13 +1100)]
rustdoc: add table-of-contents recording & rendering, use it with plain
markdown files.

This means that

    # Foo
    ## Bar
    # Baz
    ### Qux
    ## Quz

Gets a TOC like

    1 Foo
       1.1 Bar
    2 Baz
       2.0.1 Qux
       2.1 Quz

This functionality is only used when rendering a single markdown file,
never on an individual module, although it could very feasibly be
extended to allow modules to opt-in to a table of contents (std::fmt
comes to mind).

10 years agorustdoc: run on plain Markdown files.
Huon Wilson [Fri, 7 Mar 2014 03:31:41 +0000 (14:31 +1100)]
rustdoc: run on plain Markdown files.

This theoretically gives rustdoc the ability to render our guides,
tutorial and manual (not in practice, since the files themselves need to
be adjusted slightly to use Sundown-compatible functionality).

Fixes #11392.

10 years agoauto merge of #12777 : sfackler/rust/no_run, r=alexcrichton
bors [Sun, 9 Mar 2014 06:41:45 +0000 (22:41 -0800)]
auto merge of #12777 : sfackler/rust/no_run, r=alexcrichton

This is useful for code that would be expensive to run or has some kind
of external dependency (e.g. a database or server).

10 years agoauto merge of #12758 : rgawdzik/rust/master, r=alexcrichton
bors [Sun, 9 Mar 2014 04:51:48 +0000 (20:51 -0800)]
auto merge of #12758 : rgawdzik/rust/master, r=alexcrichton

Refactored get_metadata_section to return a Result<MetadataBlob,~str> instead of a Option<MetadataBlob>. This provides more clarity to the user through the debug output when using --ls.

This is kind of a continuation of my original closed pull request 2 months ago (#11544), but I think the time-span constitutes a new pull request.

10 years agoAdd an option to not run rustdoc blocks
Steven Fackler [Sun, 9 Mar 2014 03:39:01 +0000 (19:39 -0800)]
Add an option to not run rustdoc blocks

This is useful for code that would be expensive to run or has some kind
of external dependency (e.g. a database or server).

10 years agoauto merge of #12706 : pongad/rust/issue_12698, r=brson
bors [Sun, 9 Mar 2014 03:06:48 +0000 (19:06 -0800)]
auto merge of #12706 : pongad/rust/issue_12698, r=brson

Fixes #12698

10 years agoRefactored get_metadata_section to return a Result<T,~str>, added error messages...
Robert Gawdzik [Fri, 7 Mar 2014 22:37:18 +0000 (17:37 -0500)]
Refactored get_metadata_section to return a Result<T,~str>, added error messages. Closes #6615.

10 years agoauto merge of #12759 : lucab/rust/char-doc, r=alexcrichton
bors [Sun, 9 Mar 2014 01:31:57 +0000 (17:31 -0800)]
auto merge of #12759 : lucab/rust/char-doc, r=alexcrichton

This is mostly a reaction to #12730. If we are going to keep calling them `char`, at least make it clear that they aren't characters but codepoint/scalar.

10 years agoauto merge of #12768 : pnkfelix/rust/fsk-devecing, r=pnkfelix
bors [Sat, 8 Mar 2014 21:01:55 +0000 (13:01 -0800)]
auto merge of #12768 : pnkfelix/rust/fsk-devecing, r=pnkfelix

Change `~[T]` to Vec<T> in librustc.  Rebased and amended version of PR #12716.

Original author (or perhaps I should say meta-author) was @pcwalton, as is reflected in the commits.

I clean up!  :)

10 years agoIncorporated review feedback atop pcwalton's original patches.
Felix S. Klock II [Sat, 8 Mar 2014 20:47:12 +0000 (21:47 +0100)]
Incorporated review feedback atop pcwalton's original patches.

(Original PR was #12716; feedback was provided by thestinger and me.)

10 years agolibrustdoc: Fix librustdoc for the `Vec<T>` change.
Patrick Walton [Wed, 5 Mar 2014 19:04:36 +0000 (11:04 -0800)]
librustdoc: Fix librustdoc for the `Vec<T>` change.

10 years agolibrustc: Fix up fallout from the automatic conversion.
Felix S. Klock II [Sat, 8 Mar 2014 20:36:22 +0000 (21:36 +0100)]
librustc: Fix up fallout from the automatic conversion.

10 years agolibrustc: Automatically change uses of `~[T]` to `Vec<T>` in rustc.
Patrick Walton [Tue, 4 Mar 2014 18:02:49 +0000 (10:02 -0800)]
librustc: Automatically change uses of `~[T]` to `Vec<T>` in rustc.

10 years agoRemoved DeepClone. Issue #12698.
Michael Darakananda [Wed, 5 Mar 2014 06:19:14 +0000 (01:19 -0500)]
Removed DeepClone. Issue #12698.

10 years agolibstd: Add some more functionality to Vec<T>
Patrick Walton [Tue, 4 Mar 2014 18:39:49 +0000 (10:39 -0800)]
libstd: Add some more functionality to Vec<T>

10 years agodoc: add two missing char methods doc-strings
Luca Bruno [Fri, 7 Mar 2014 23:27:49 +0000 (00:27 +0100)]
doc: add two missing char methods doc-strings

XID_* property are defined in UAX #31, just reference it here.

Signed-off-by: Luca Bruno <lucab@debian.org>
10 years agodoc: uniform std::char doc-strings
Luca Bruno [Fri, 7 Mar 2014 23:13:54 +0000 (00:13 +0100)]
doc: uniform std::char doc-strings

Uniform and beautify doc-string for current rustdoc output.

Signed-off-by: Luca Bruno <lucab@debian.org>
10 years agodoc: don't refer to 'char' as characters
Luca Bruno [Fri, 7 Mar 2014 22:53:34 +0000 (23:53 +0100)]
doc: don't refer to 'char' as characters

This seems to be causing some confusion among users. Rust's char are
not 8bit characters, but 32bit UCS-4 codepoint without surrogates
(Unicode Scalar Values as per Unicode glossary).
Make the doc more explicit about it.

Signed-off-by: Luca Bruno <lucab@debian.org>
10 years agoauto merge of #12520 : thestinger/rust/cmp, r=brson
bors [Sat, 8 Mar 2014 04:36:42 +0000 (20:36 -0800)]
auto merge of #12520 : thestinger/rust/cmp, r=brson

* `Ord` inherits from `Eq`
* `TotalOrd` inherits from `TotalEq`
* `TotalOrd` inherits from `Ord`
* `TotalEq` inherits from `Eq`

This is a partial implementation of #12517.

10 years agocreate a sensible comparison trait hierarchy
Daniel Micay [Mon, 24 Feb 2014 13:11:00 +0000 (08:11 -0500)]
create a sensible comparison trait hierarchy

* `Ord` inherits from `Eq`
* `TotalOrd` inherits from `TotalEq`
* `TotalOrd` inherits from `Ord`
* `TotalEq` inherits from `Eq`

This is a partial implementation of #12517.

10 years agoauto merge of #12748 : liigo/rust/rust-birthday, r=brson
bors [Sat, 8 Mar 2014 03:21:51 +0000 (19:21 -0800)]
auto merge of #12748 : liigo/rust/rust-birthday, r=brson

Rust v0.1 was released on January 20, 2012:
https://mail.mozilla.org/pipermail/rust-dev/2012-January/001256.html

10 years agoauto merge of #12752 : edwardw/rust/rdoc, r=alexcrichton
bors [Sat, 8 Mar 2014 01:16:52 +0000 (17:16 -0800)]
auto merge of #12752 : edwardw/rust/rdoc, r=alexcrichton

A structure's definition and implementation may be cross-module. If the
implementing module is parsed before defining module, the fully
qualified name of the structure won't be present for the implementation
to use when being indexed. So caches such 'orphan' implementation and
indexes it at the end of crate parsing.

Closes #10284.

10 years agoIndex cross-mod type definition and implementation properly in rustdoc
Edward Wang [Fri, 7 Mar 2014 09:26:06 +0000 (17:26 +0800)]
Index cross-mod type definition and implementation properly in rustdoc

A structure's definition and implementation may be cross-module. If the
implementing module is parsed before defining module, the fully
qualified name of the structure won't be present for the implementation
to use when being indexed. So caches such 'orphan' implementation and
indexes it at the end of crate parsing.

Closes #10284.

10 years agoauto merge of #12753 : huonw/rust/vec-macro, r=cmr
bors [Fri, 7 Mar 2014 10:51:39 +0000 (02:51 -0800)]
auto merge of #12753 : huonw/rust/vec-macro, r=cmr

If no arguments are given to `vec!` then no pushes are emitted and
so the compiler (rightly) complains that the mutability of `temp` is
never used.

This behaviour is rather annoying for users.

10 years agoauto merge of #12750 : liigo/rust/De-extern-mod, r=alexcrichton
bors [Fri, 7 Mar 2014 09:01:40 +0000 (01:01 -0800)]
auto merge of #12750 : liigo/rust/De-extern-mod, r=alexcrichton

rename ast::ViewItemExternMod to ast::ViewItemExternCrate
rename rustdoc::clean::ExternMod to rustdoc::clean::ExternCrate
because `extern mod` is out.

10 years agorename ast::ViewItemExternMod to ast::ViewItemExternCrate, and clean::ExternMod to...
Liigo Zhuang [Fri, 7 Mar 2014 07:57:45 +0000 (15:57 +0800)]
rename ast::ViewItemExternMod to ast::ViewItemExternCrate, and clean::ExternMod to clean::ExternCrate

10 years agoauto merge of #12749 : tedhorst/rust/master, r=huonw
bors [Fri, 7 Mar 2014 07:46:40 +0000 (23:46 -0800)]
auto merge of #12749 : tedhorst/rust/master, r=huonw

Minor change to the FVN hashing function based on recommendation on: http://en.wikipedia.org/wiki/Fowler_Noll_Vo_hash

cc @alexcrichton

10 years agochange FVN hash function to the FVN-1a variant
Ted Horst [Fri, 7 Mar 2014 07:25:25 +0000 (01:25 -0600)]
change FVN hash function to the FVN-1a variant

10 years agoExplicitly write down 0.1 release date in RELEASES.txt, to confirm Rust's birthday.
Liigo Zhuang [Fri, 7 Mar 2014 07:05:05 +0000 (15:05 +0800)]
Explicitly write down 0.1 release date in RELEASES.txt, to confirm Rust's birthday.

10 years agostd: stop `vec!()` warning about unused mutability.
Huon Wilson [Fri, 7 Mar 2014 07:07:25 +0000 (18:07 +1100)]
std: stop `vec!()` warning about unused mutability.

If no arguments are given to `vec!` then no pushes are emitted and
so the compiler (rightly) complains that the mutability of `temp` is
never used.

This behaviour is rather annoying for users.

10 years agoauto merge of #12746 : alexcrichton/rust/issue-12743, r=brson
bors [Fri, 7 Mar 2014 03:31:37 +0000 (19:31 -0800)]
auto merge of #12746 : alexcrichton/rust/issue-12743, r=brson

The arguments were accidentally swapped in the wrong order.

Closes #12743

10 years agoauto merge of #12635 : alexcrichton/rust/speedy-hash, r=brson
bors [Fri, 7 Mar 2014 02:16:39 +0000 (18:16 -0800)]
auto merge of #12635 : alexcrichton/rust/speedy-hash, r=brson

This leverages the new hashing framework and hashmap implementation to provide a
much speedier hashing algorithm for node ids and def ids. The hash algorithm
used is currentl FNV hashing, but it's quite easy to swap out.

I originally implemented hashing as the identity function, but this actually
ended up in slowing down rustc compiling libstd from 8s to 13s. I would suspect
that this is a result of a large number of collisions.

With FNV hashing, we get these timings (compiling with --no-trans, in seconds):

|           |  before  |  after  |
|-----------|---------:|--------:|
| libstd    |   8.324  |  6.703  |
| stdtest   |  47.674  | 46.857  |
| libsyntax |   9.918  |  8.400  |

10 years agosyntax: Conditionally deriving(Hash) with Writers
Alex Crichton [Sat, 1 Mar 2014 07:17:38 +0000 (23:17 -0800)]
syntax: Conditionally deriving(Hash) with Writers

If #[feature(default_type_parameters)] is enabled for a crate, then
deriving(Hash) will expand with Hash<W: Writer> instead of Hash<SipState> so
more hash algorithms can be used.

10 years agocollections: Correct with_capacity_and_hasher
Alex Crichton [Fri, 7 Mar 2014 02:07:52 +0000 (18:07 -0800)]
collections: Correct with_capacity_and_hasher

The arguments were accidentally swapped in the wrong order.

Closes #12743

10 years agorustc: Move to FNV hashing for node/def ids
Alex Crichton [Fri, 28 Feb 2014 22:34:26 +0000 (14:34 -0800)]
rustc: Move to FNV hashing for node/def ids

This leverages the new hashing framework and hashmap implementation to provide a
much speedier hashing algorithm for node ids and def ids. The hash algorithm
used is currentl FNV hashing, but it's quite easy to swap out.

I originally implemented hashing as the identity function, but this actually
ended up in slowing down rustc compiling libstd from 8s to 13s. I would suspect
that this is a result of a large number of collisions.

With FNV hashing, we get these timings (compiling with --no-trans, in seconds):

|           |  before  |  after  |
|-----------|---------:|--------:|
| libstd    |   8.324  |  6.703  |
| stdtest   |  47.674  | 46.857  |
| libsyntax |   9.918  |  8.400  |

10 years agoauto merge of #12738 : alexcrichton/rust/needstest, r=brson,just
bors [Thu, 6 Mar 2014 23:11:42 +0000 (15:11 -0800)]
auto merge of #12738 : alexcrichton/rust/needstest, r=brson,just

Closes #6738
Closes #7061
Closes #7899
Closes #9719
Closes #10028
Closes #10228
Closes #10401
Closes #11192
Closes #11508
Closes #11529
Closes #11873
Closes #11925

10 years agoauto merge of #12737 : alexcrichton/rust/issue-12736, r=brson
bors [Thu, 6 Mar 2014 21:56:41 +0000 (13:56 -0800)]
auto merge of #12737 : alexcrichton/rust/issue-12736, r=brson

Turns out sundown has already escaped this content for us, so there's no need
for us to escape it again.

Closes #12736

10 years agoauto merge of #12732 : klutzy/rust/this-is-windows, r=alexcrichton
bors [Thu, 6 Mar 2014 20:37:01 +0000 (12:37 -0800)]
auto merge of #12732 : klutzy/rust/this-is-windows, r=alexcrichton

On Windows, `LLVMRustGetLastError()` may return non-utf8 mojibake string
if system uses non-English locale. It caused ICE when llvm fails.
This patch doesn't fix the real problem, but just make rustc not die.

10 years agotest: Add some tests for closed issues
Alex Crichton [Thu, 6 Mar 2014 17:55:35 +0000 (09:55 -0800)]
test: Add some tests for closed issues

Closes #6738
Closes #7061
Closes #7899
Closes #9719
Closes #10028
Closes #10228
Closes #10401
Closes #11192
Closes #11508
Closes #11529
Closes #11873
Closes #11925

10 years agoauto merge of #12720 : iliekturtles/rust/master, r=alexcrichton
bors [Thu, 6 Mar 2014 18:36:50 +0000 (10:36 -0800)]
auto merge of #12720 : iliekturtles/rust/master, r=alexcrichton

10 years agorustdoc: Don't escape contents of headers
Alex Crichton [Thu, 6 Mar 2014 17:34:04 +0000 (09:34 -0800)]
rustdoc: Don't escape contents of headers

Turns out sundown has already escaped this content for us, so there's no need
for us to escape it again.

Closes #12736

10 years agoAdded missing possessive apostrophe.
Mike Boutin [Thu, 6 Mar 2014 01:29:52 +0000 (20:29 -0500)]
Added missing possessive apostrophe.

10 years agorustc: Get LLVM error message safely
klutzy [Thu, 6 Mar 2014 14:57:31 +0000 (23:57 +0900)]
rustc: Get LLVM error message safely

On Windows, `LLVMRustGetLastError()` may return non-utf8 mojibake string
if system uses non-English locale. It caused ICE when llvm fails.
This patch doesn't fix the real problem, but just make rustc not die.

10 years agoauto merge of #12727 : lifthrasiir/rust/buffalo-buffalo, r=huonw
bors [Thu, 6 Mar 2014 14:51:35 +0000 (06:51 -0800)]
auto merge of #12727 : lifthrasiir/rust/buffalo-buffalo, r=huonw

Cosmetic changes at best, but there are so many such typos that I couldn't ignore them. :) Some occurrences of typos are linked to the generated documentations but no changes should break the builds.

10 years agoauto merge of #12726 : alexcrichton/rust/travis, r=brson
bors [Thu, 6 Mar 2014 13:06:39 +0000 (05:06 -0800)]
auto merge of #12726 : alexcrichton/rust/travis, r=brson

This version is slightly more up to date and is closer to the 3.5 that we're
using. This also updates the travis config to have a build matrix which tests
rust against LLVM 3.3 and 3.4. For pull requests only LLVM 3.4 is tested to
reduce the load on travis.

This is mostly just fluff, there's no real reason to gate rust on these results,
it's more of just a nice thing to know when we break compatibility with LLVM 3.3
and 3.4 (and eventually 3.5). This turns off notifications of failed commits
(which are sent out for pushes to master).

10 years agofix typos with with repeated words, just like this sentence.
Kang Seonghoon [Thu, 6 Mar 2014 07:35:12 +0000 (16:35 +0900)]
fix typos with with repeated words, just like this sentence.

10 years agoauto merge of #12719 : alexcrichton/rust/fix-llvm-33, r=brson
bors [Thu, 6 Mar 2014 11:11:39 +0000 (03:11 -0800)]
auto merge of #12719 : alexcrichton/rust/fix-llvm-33, r=brson

The llvm.copysign and llvm.round intrinsics weren't added until LLVM 3.4, so if
we're on LLVM 3.3 we lower these to calls in libm instead of LLVM intrinsics.

This should fix our travis failures.

10 years agoauto merge of #12714 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton
bors [Thu, 6 Mar 2014 09:56:43 +0000 (01:56 -0800)]
auto merge of #12714 : michaelwoerister/rust/limited-debuginfo, r=alexcrichton

This PR brings back limited debuginfo which allows for nice backtraces and breakpoints, but omits any info about variables and types.

The `-g` and `--debuginfo` command line options have been extended to take an optional argument:
`-g0` means no debug info.
`-g1` means line-tables only.
`-g2` means full debug info.

Specifying `-g` without argument is equivalent to `-g2`.

Fixes #12280

10 years agoauto merge of #12705 : alexcrichton/rust/issue-12692, r=brson
bors [Thu, 6 Mar 2014 08:41:48 +0000 (00:41 -0800)]
auto merge of #12705 : alexcrichton/rust/issue-12692, r=brson

Details are in the commit messages, but this closes a few issues seen with `libnative` recently.