Commit Graph

95 Commits

Author SHA1 Message Date
Richo Healey 553074506e core: rename strbuf::StrBuf to string::String
[breaking-change]
2014-05-24 21:48:10 -07:00
Patrick Walton 36195eb91f libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`. 2014-05-22 14:42:01 -07:00
Felix S. Klock II eb6856c307 Fixing rustdoc stage1.
See #13983 and #14000.

Fix was originally authored by alexcrichton and then rebased a couple
times by pnkfelix, most recently atop PR 13954.

----

Regarding the change to librustdoc/lib.rs, to do `map_err` before
unwrapping a `TqskResult`: I do not understand how master is passing
without this change or something like it, since `Box<Any:Send>` does
not implement `Show`.  (Is this something that is only a problem for
the snapshot stage0 compiler?)  Still, the change I have put in here
(which was added as part of a rebase after alex's review) seems
harmless to me to apply to rustdoc at all stages, since a call to
`unwrap` is just going to `fail!` on the err case anyway.
2014-05-18 22:56:19 +02:00
Patrick Walton 1fb08f11b7 libgetopts: Remove all uses of `~str` from `libgetopts` 2014-05-16 11:41:27 -07:00
Patrick Walton 28bcef85e4 libserialize: Remove all uses of `~str` from `libserialize`.
Had to make `struct Tm` in `libtime` not serializable for now.
2014-05-16 11:41:27 -07:00
Brian Anderson 67fa90e48a Print 'rustc' and 'rustdoc' as the command name for --version
Instead of just blindly printing arg[0], use a constant string.
Partial fix for #13582
2014-05-14 15:34:14 -07:00
Brian Anderson c1da4f875f Add the patch number to version strings. Closes #13289 2014-05-12 19:52:29 -07:00
Patrick Walton 9ba91e1243 librustdoc: Remove all `~str` usage from librustdoc. 2014-05-12 17:57:26 -07:00
Nick Cameron 37ca36783c Reorganise driver code.
The goal of this refactoring is to make the rustc driver code easier to understand and use. Since this is as close to an API as we have, I think it is important that it is nice. On getting stuck in, I found that there wasn't as much to change as I'd hoped to make the stage... fns easier to use by tools.

This patch only moves code around - mostly just moving code to different files, but a few extracted method refactorings too. To summarise the changes: I added driver::config which handles everything about configuring the compiler. driver::session now just defines and builds session objects. I moved driver code from librustc/lib.rs to librustc/driver/mod.rs so all the code is one place. I extracted methods to make emulating the compiler without being the compiler a little easier. Within the driver directory, I moved code around to more logically fit in the modules.
2014-05-11 11:08:01 +12:00
Kevin Ballard 752048a271 Handle more fallout
os::args() no longer auto-borrows to &[~str].
2014-05-08 12:06:22 -07:00
Alex Crichton ab92ea526d std: Modernize the local_data api
This commit brings the local_data api up to modern rust standards with a few key
improvements:

* The `pop` and `set` methods have been combined into one method, `replace`

* The `get_mut` method has been removed. All interior mutability should be done
  through `RefCell`.

* All functionality is now exposed as a method on the keys themselves. Instead
  of importing std::local_data, you now use "key.replace()" and "key.get()".

* All closures have been removed in favor of RAII functionality. This means that
  get() and get_mut() no long require closures, but rather return
  Option<SmartPointer> where the smart pointer takes care of relinquishing the
  borrow and also implements the necessary Deref traits

* The modify() function was removed to cut the local_data interface down to its
  bare essentials (similarly to how RefCell removed set/get).

[breaking-change]
2014-05-07 23:43:39 -07:00
Brian Anderson a5be12ce7e Replace most ~exprs with 'box'. #11779 2014-05-02 23:00:58 -07:00
Jonathan S 03609e5a5e Deprecate the rev_iter pattern in all places where a DoubleEndedIterator is provided (everywhere but treemap)
This commit deprecates rev_iter, mut_rev_iter, move_rev_iter everywhere (except treemap) and also
deprecates related functions like rsplit, rev_components, and rev_str_components. In every case,
these functions can be replaced with the non-reversed form followed by a call to .rev(). To make this
more concrete, a translation table for all functional changes necessary follows:

* container.rev_iter() -> container.iter().rev()
* container.mut_rev_iter() -> container.mut_iter().rev()
* container.move_rev_iter() -> container.move_iter().rev()
* sliceorstr.rsplit(sep) -> sliceorstr.split(sep).rev()
* path.rev_components() -> path.components().rev()
* path.rev_str_components() -> path.str_components().rev()

In terms of the type system, this change also deprecates any specialized reversed iterator types (except
in treemap), opting instead to use Rev directly if any type annotations are needed. However, since
methods directly returning reversed iterators are now discouraged, the need for such annotations should
be small. However, in those cases, the general pattern for conversion is to take whatever follows Rev in
the original reversed name and surround it with Rev<>:

* RevComponents<'a> -> Rev<Components<'a>>
* RevStrComponents<'a> -> Rev<StrComponents<'a>>
* RevItems<'a, T> -> Rev<Items<'a, T>>
* etc.

The reasoning behind this change is that it makes the standard API much simpler without reducing readability,
performance, or power. The presence of functions such as rev_iter adds more boilerplate code to libraries
(all of which simply call .iter().rev()), clutters up the documentation, and only helps code by saving two
characters. Additionally, the numerous type synonyms that were used to make the type signatures look nice
like RevItems add even more boilerplate and clutter up the docs even more. With this change, all that cruft
goes away.

[breaking-change]
2014-04-28 16:45:36 -05:00
Kang Seonghoon bec77eb9c5 rustdoc: Moved `SCHEMA_VERSION` to `clean`.
it should be changed when the module gets updated, so it helps to
have the `SCHEMA_VERSION` with the definitions themselves.
2014-04-26 22:45:50 +09:00
Richo Healey 919889a1d6 Replace all ~"" with "".to_owned() 2014-04-18 17:25:34 -07:00
Kang Seonghoon f1de04c760 rustdoc: Represent item types as a small number in the search index.
Has negligible improvements with gzip, but saves about 7% without it.
This also has an effect of changing the tie-breaking order of item types.
2014-04-14 10:00:48 +09:00
bors e4779b5050 auto merge of #13165 : sfackler/rust/io-vec, r=alexcrichton
`Reader`, `Writer`, `MemReader`, `MemWriter`, and `MultiWriter` now work with `Vec<u8>` instead of `~[u8]`. This does introduce some extra copies since `from_utf8_owned` isn't usable anymore, but I think that can't be helped until `~str`'s representation changes.
2014-04-06 23:36:38 -07:00
Steven Fackler 49a8081095 De-~[] Mem{Reader,Writer} 2014-04-06 15:40:01 -07:00
Corey Richardson 0459ee77d0 Fix fallout from std::libc separation 2014-04-04 09:31:44 -07:00
bors 540c2a2a27 auto merge of #13255 : alexcrichton/rust/issue-5605, r=huonw
These syntax extensions need a place to be documented, and this starts passing a
`--cfg dox` parameter to `rustdoc` when building and testing documentation in
order to document macros so that they have no effect on the compiled crate, but
only documentation.

Closes #5605
2014-04-04 01:01:51 -07:00
Brian Anderson 0875ffcbff Bump version to 0.11-pre
This also changes some of the download links in the documentation
to 'nightly'.
2014-04-03 16:28:46 -07:00
Alex Crichton 78937b9779 std: Document builtin syntax extensions
These syntax extensions need a place to be documented, and this starts passing a
`--cfg dox` parameter to `rustdoc` when building and testing documentation in
order to document macros so that they have no effect on the compiled crate, but
only documentation.

Closes #5605
2014-04-03 16:17:48 -07:00
Alex Crichton a5681d2590 Bump version to 0.10 2014-03-31 14:40:44 -07:00
bors df9cf18c10 auto merge of #13188 : FlaPer87/rust/master, r=alexcrichton 2014-03-29 02:56:40 -07:00
Flavio Percoco a9c6061c9a Register new snapshot 2014-03-29 01:12:32 +01:00
Brian Anderson 451e8c1c61 Convert most code to new inner attribute syntax.
Closes #2569
2014-03-28 17:12:21 -07:00
Sean McArthur f1739b14a1 serialize: use Result
All of Decoder and Encoder's methods now return a Result.

Encodable.encode() and Decodable.decode() return a Result as well.

fixes #12292
2014-03-27 17:41:55 -07:00
Patrick Walton af79a5aa7d test: Make manual changes to deal with the fallout from removal of
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
2014-03-21 23:37:21 +11:00
Alex Crichton da3625161d Removing imports of std::vec_ng::Vec
It's now in the prelude.
2014-03-20 09:30:14 -07:00
Alex Crichton 848f7b734e rustdoc: Implement cross-crate searching
A major discoverability issue with rustdoc is that all crates have their
documentation built in isolation, so it's difficult when looking at the
documentation for libstd to learn that there's a libcollections crate with a
HashMap in it.

This commit moves rustdoc a little closer to improving the multiple crate
experience. This unifies all search indexes for all crates into one file so all
pages share the same search index. This allows searching to work across crates
in the same documentation directory (as the standard distribution is currently
built).

This strategy involves updating a shared file amongst many rustdoc processes, so
I implemented a simple file locking API for handling synchronization for updates
to the shared files.

cc #12554
2014-03-18 13:51:29 -07:00
Eduard Burtescu e2ebc8f811 Fix rustdoc and tests. 2014-03-17 09:55:41 +02:00
Eduard Burtescu f77c744142 De-@ filesearch. 2014-03-17 09:53:07 +02:00
Alex Crichton cc6ec8df95 log: Introduce liblog, the old std::logging
This commit moves all logging out of the standard library into an external
crate. This crate is the new crate which is responsible for all logging macros
and logging implementation. A few reasons for this change are:

* The crate map has always been a bit of a code smell among rust programs. It
  has difficulty being loaded on almost all platforms, and it's used almost
  exclusively for logging and only logging. Removing the crate map is one of the
  end goals of this movement.

* The compiler has a fair bit of special support for logging. It has the
  __log_level() expression as well as generating a global word per module
  specifying the log level. This is unfairly favoring the built-in logging
  system, and is much better done purely in libraries instead of the compiler
  itself.

* Initialization of logging is much easier to do if there is no reliance on a
  magical crate map being available to set module log levels.

* If the logging library can be written outside of the standard library, there's
  no reason that it shouldn't be. It's likely that we're not going to build the
  highest quality logging library of all time, so third-party libraries should
  be able to provide just as high-quality logging systems as the default one
  provided in the rust distribution.

With a migration such as this, the change does not come for free. There are some
subtle changes in the behavior of liblog vs the previous logging macros:

* The core change of this migration is that there is no longer a physical
  log-level per module. This concept is still emulated (it is quite useful), but
  there is now only a global log level, not a local one. This global log level
  is a reflection of the maximum of all log levels specified. The previously
  generated logging code looked like:

    if specified_level <= __module_log_level() {
        println!(...)
    }

  The newly generated code looks like:

    if specified_level <= ::log::LOG_LEVEL {
        if ::log::module_enabled(module_path!()) {
            println!(...)
        }
    }

  Notably, the first layer of checking is still intended to be "super fast" in
  that it's just a load of a global word and a compare. The second layer of
  checking is executed to determine if the current module does indeed have
  logging turned on.

  This means that if any module has a debug log level turned on, all modules
  with debug log levels get a little bit slower (they all do more expensive
  dynamic checks to determine if they're turned on or not).

  Semantically, this migration brings no change in this respect, but
  runtime-wise, this will have a perf impact on some code.

* A `RUST_LOG=::help` directive will no longer print out a list of all modules
  that can be logged. This is because the crate map will no longer specify the
  log levels of all modules, so the list of modules is not known. Additionally,
  warnings can no longer be provided if a malformed logging directive was
  supplied.

The new "hello world" for logging looks like:

    #[phase(syntax, link)]
    extern crate log;

    fn main() {
        debug!("Hello, world!");
    }
2014-03-15 22:26:36 -07:00
Alex Crichton 58e4ab2b33 extra: Put the nail in the coffin, delete libextra
This commit shreds all remnants of libextra from the compiler and standard
distribution. Two modules, c_vec/tempfile, were moved into libstd after some
cleanup, and the other modules were moved to separate crates as seen fit.

Closes #8784
Closes #12413
Closes #12576
2014-03-14 13:59:02 -07:00
Huon Wilson 62792f09f2 lint: add lint for use of a `~[T]`.
This is useless at the moment (since pretty much every crate uses
`~[]`), but should help avoid regressions once completely removed from a
crate.
2014-03-14 11:28:39 +11:00
Michael Darakananda f079c94f72 rustc: Remove matching on ~str from the language
The `~str` type is not long for this world as it will be superseded by the
soon-to-come DST changes for the language. The new type will be
`~Str`, and matching over the allocation will no longer be supported.
Matching on `&str` will continue to work, in both a pre and post DST world.
2014-03-12 19:17:36 -04:00
Huon Wilson f22c96cc88 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).
2014-03-09 19:29:49 +11:00
Huon Wilson 69b8ef806b 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.
2014-03-09 19:29:49 +11:00
Alex Crichton 6485917d7c Move extra::json to libserialize
This also inverts the dependency between libserialize and libcollections.

cc #8784
2014-02-24 09:51:39 -08:00
Nick Cameron 317a253b22 All uses of `extern fn` should mean `extern "C" fn`. Closes #9309. 2014-02-24 13:24:57 +13:00
Alex Crichton ad9e26dab3 rustdoc: Add syntax highlighting
This adds simple syntax highlighting based off libsyntax's lexer to be sure to
stay up to date with rust's grammar. Some of the highlighting is a bit ad-hoc,
but it definitely seems to get the job done!

This currently doesn't highlight rustdoc-rendered function signatures and
structs that are emitted to each page because the colors already signify what's
clickable and I think we'd have to figure out a different scheme before
colorizing them. This does, however, colorize all code examples and source code.

Closes #11393
2014-02-23 00:16:23 -08:00
Arcterus 66f93291ec Move time out of extra (cc #8784) 2014-02-21 07:44:11 -08:00
Alex Crichton 7bb498bd7a Mass rename if_ok! to try!
This "bubble up an error" macro was originally named if_ok! in order to get it
landed, but after the fact it was discovered that this name is not exactly
desirable.

The name `if_ok!` isn't immediately clear that is has much to do with error
handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In
general, the agreed opinion about `if_ok!` is that is came in as subpar.

The name `try!` is more invocative of error handling, it's shorter by 2 letters,
and it looks fitting in almost all circumstances. One concern about the word
`try!` is that it's too invocative of exceptions, but the belief is that this
will be overcome with documentation and examples.

Close #12037
2014-02-20 09:16:52 -08:00
Liigo Zhuang 53b9d1a324 move extra::test to libtest 2014-02-20 16:03:58 +08:00
Alex Crichton 68d576fd34 rustdoc: Fix json output and input
Turns out a hash map with integer keys isn't serializable to json.

Closes #10115
2014-02-19 01:10:31 -08:00
bors 57d273f65e auto merge of #12284 : brson/rust/install, r=alexcrichton
Work toward #9876.

This adds `prepare.mk`, which is simply a more heavily-parameterized `install.mk`, then uses `prepare` to implement both `install` and the windows installer (`dist`). Smoke tested on both Linux and Windows.
2014-02-17 03:26:51 -08:00
Brian Anderson 2b64cb294c Address review feedback 2014-02-16 17:36:43 -08:00
Brendan Zabarauskas cf0654c47c Improve naming of tuple getters, and add mutable tuple getter
Renames the `n*` and `n*_ref` tuple getters to `val*` and `ref*` respectively, and adds `mut*` getters.
2014-02-17 00:57:56 +11:00
Alex Crichton a41b0c2529 extern mod => extern crate
This was previously implemented, and it just needed a snapshot to go through
2014-02-14 22:55:21 -08:00
Flavio Percoco 968633b60a Replace `crate` usage with `krate`
This patch replaces all `crate` usage with `krate` before introducing the
new keyword. This ensures that after introducing the keyword, there
won't be any compilation errors.

krate might not be the most expressive substitution for crate but it's a
very close abbreviation for it. `module` was already used in several
places already.
2014-02-13 20:52:07 +01:00