Commit Graph

27039 Commits

Author SHA1 Message Date
bors
84ebf74ee2 auto merge of #12607 : alexcrichton/rust/io++, r=brson
This lowers the #[allow(missing_doc)] directive into some of the lower modules
which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-28 12:06:30 -08:00
Alex Crichton
324547140e syntax: Refactor diagnostics to focus on Writers
This commit alters the diagnostic emission machinery to be focused around a
Writer for emitting errors. This allows it to not hard-code emission of errors
to stderr (useful for other applications).
2014-02-28 11:37:04 -08:00
bors
58ea029db2 auto merge of #12533 : alexcrichton/rust/svh, r=brson
These hashes are used to detect changes to upstream crates and generate errors which mention that crates possibly need recompilation.

More details can be found in the respective commit messages below. This change is also accompanied with a much needed refactoring of some of the crate loading code to focus more on crate ids instead of name/version pairs.

Closes #12601
2014-02-28 10:51:34 -08:00
Alex Crichton
311ac8f480 std: Improve some I/O documentation
This lowers the #[allow(missing_doc)] directive into some of the lower modules
which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-28 10:49:34 -08:00
Alex Crichton
017c504489 syntax: Expand format!() deterministically
Previously, format!("{a}{b}", a=foo(), b=bar()) has foo() and bar() run in a
nondeterminisc order. This is clearly a non-desirable property, so this commit
uses iteration over a list instead of iteration over a hash map to provide
deterministic code generation of these format arguments.
2014-02-28 10:48:04 -08:00
Alex Crichton
ec57db083f rustc: Add the concept of a Strict Version Hash
This new SVH is used to uniquely identify all crates as a snapshot in time of
their ABI/API/publicly reachable state. This current calculation is just a hash
of the entire crate's AST. This is obviously incorrect, but it is currently the
reality for today.

This change threads through the new Svh structure which originates from crate
dependencies. The concept of crate id hash is preserved to provide efficient
matching on filenames for crate loading. The inspected hash once crate metadata
is opened has been changed to use the new Svh.

The goal of this hash is to identify when upstream crates have changed but
downstream crates have not been recompiled. This will prevent the def-id drift
problem where upstream crates were recompiled, thereby changing their metadata,
but downstream crates were not recompiled.

In the future this hash can be expanded to exclude contents of the AST like doc
comments, but limitations in the compiler prevent this change from being made at
this time.

Closes #10207
2014-02-28 10:48:04 -08:00
Alex Crichton
8213e18447 rustc: Simplify crate loading constraints
The previous code passed around a {name,version} pair everywhere, but this is
better expressed as a CrateId. This patch changes these paths to store and pass
around crate ids instead of these pairs of name/version. This also prepares the
code to change the type of hash that is stored in crates.
2014-02-28 10:47:41 -08:00
Alex Crichton
d5aa795aa5 std: Add cfg(test) to UnsafeArc assertions
This is a ubiquitous type in concurrent code, and the assertions are causing
significant code bloat for simple operations such as reading the pointer
(injecting a failure point, etc).

I am testing executable sizes with no I/O implementations (everything stubbed
out to return nothing), and this took the size of a libnative executable from
328K to 207K (37% reduction in size), so I think that this is one assertion
that's well worth configuring off for now.
2014-02-28 10:46:12 -08:00
bors
9b1be3d182 auto merge of #12622 : pnkfelix/rust/fsk-improve-vec-partition-doc, r=huonw
Explicitly note in vec `partition` and `partitioned` that the left and
right parts each map to satisfying and non-satisfying elements.
2014-02-28 07:26:30 -08:00
bors
2e51e8d926 auto merge of #12595 : huonw/rust/pub-vis-typ, r=alexcrichton
These are types that are in exported type signatures, but are not
exported themselves, e.g.

    struct Foo { ... }

    pub fn bar() -> Foo { ... }

will warn about the Foo.

Such types are not listed in documentation, and cannot be named outside
the crate in which they are declared, which is very user-unfriendly.

cc #10573.
2014-02-28 06:06:31 -08:00
Felix S. Klock II
daa6da766a Improve vec partition and partitioned method doc.
Explicitly note in vec `partition` and `partitioned` that the left and
right parts each map to satisfying and non-satisfying elements.
2014-02-28 14:15:29 +01:00
Huon Wilson
218eae06ab Publicise types/add #[allow(visible_private_types)] to a variety of places.
There's a lot of these types in the compiler libraries, and a few of the
older or private stdlib ones. Some types are obviously meant to be
public, others not so much.
2014-03-01 00:12:34 +11:00
Huon Wilson
fbdd3b2ef6 sync: Rename arc::Condvar to arc::ArcCondvar.
The sync submodule also has a `Condvar` type, and its reexport was
shadowing the `arc` type, making it crate-private.
2014-03-01 00:11:56 +11:00
Huon Wilson
859277dfdb rustc: implement a lint for publicly visible private types.
These are types that are in exported type signatures, but are not
exported themselves, e.g.

    struct Foo { ... }

    pub fn bar() -> Foo { ... }

will warn about the Foo.

Such types are not listed in documentation, and cannot be named outside
the crate in which they are declared, which is very user-unfriendly.

cc #10573
2014-03-01 00:11:56 +11:00
bors
b99a8ffad4 auto merge of #12621 : huonw/rust/time-test-doc, r=pnkfelix
Add `time` crate to index, expand docs of `test`.
2014-02-28 04:36:32 -08:00
Huon Wilson
1b5be76bdf Add time crate to index, expand docs of test. 2014-02-28 23:25:44 +11:00
bors
31e9c947a3 auto merge of #12544 : erickt/rust/hash, r=acrichto
This PR allows `HashMap`s to work with custom hashers. Also with this patch are:

* a couple generic implementations of `Hash` for a variety of types.
* added `Default`, `Clone` impls to the hashers.
* added a `HashMap::with_hasher()` constructor.
2014-02-28 00:26:34 -08:00
bors
53e90c15a6 auto merge of #12614 : alexcrichton/rust/rollup, r=alexcrichton
Closes #12546 (Add new target 'make dist-osx' to create a .pkg installer for OS X) r=brson
Closes #12575 (rustc: Move local native libs back in link-args) r=brson
Closes #12587 (Provide a more helpful error for tests that fail due to noexec) r=brson
Closes #12589 (rustc: Remove codemap and reachable from metadata encoder) r=alexcrichton
Closes #12591 (Fix syntax::ext::deriving{,::*} docs formatting.) r=huonw
Closes #12592 (Miscellaneous Vim improvements) r=alexcrichton
Closes #12596 (path: Implement windows::make_non_verbatim()) r=alexcrichton
Closes #12598 (Improve the ctags function regular expression) r=alexcrichton
Closes #12599 (Tutorial improvement (new variant of PR #12472).) r=pnkfelix
Closes #12603 (std: Export the select! macro) r=pcwalton
Closes #12605 (Fix typo in doc of Binary trait in std::fmt) r=alexcrichton
Closes #12613 (Fix bytepos_to_file_charpos) r=brson
2014-02-27 23:01:55 -08:00
bors
f203fc7daf auto merge of #12348 : brunoabinader/rust/libcollections-list-refactory, r=alexcrichton
This PR includes:
- Create an iterator for ```List<T>``` called ```Items<T>```;
- Move all list operations inside ```List<T>``` impl;
- Removed functions that are already provided by ```Iterator``` trait;
- Refactor on ```len()``` and ```is_empty``` using ```Container``` trait;
- Bunch of minor fixes;

A replacement for using @ is intended, but still in discussion.

Closes #12344.
2014-02-27 21:46:53 -08:00
Nick Cameron
a8d57a26df Fix bytepos_to_file_charpos.
Make bytepos_to_charpos relative to the start of the filemap rather than its previous behaviour which was to be realtive to the start of the codemap, but ignoring multi-byte chars in earlier filemaps. Rename to bytepos_to_file_charpos. Add tests for multi-byte chars.
2014-02-27 21:04:05 -08:00
Mickaël Delahaye
53a3f28115 Fix typo in doc of Binary trait in std::fmt 2014-02-27 21:04:05 -08:00
Alex Crichton
98782bb5c9 std: Export the select! macro
Mark it as #[experimental] for now. In theory this attribute will be read in the
future. I believe that the implementation is solid enough for general use,
although I would not be surprised if there were bugs in it still. I think that
it's at the point now where public usage of it will start to uncover hopefully
the last few remaining bugs.

Closes #12044
2014-02-27 21:04:05 -08:00
Felix S. Klock II
1bcd8252ee Minor modifications to Axel's tutorial improvements (see also #12472). 2014-02-27 21:04:05 -08:00
Axel Viala
d028079b88 Documentation : Tutorial improvement...
Refactoring examples on implementation of generics for linked list.
Fixing typo of 'Note's for coherancy.

Adding internal links inside the tutorial example with traits,
generics etc...
2014-02-27 21:04:05 -08:00
Chris Morgan
231832d835 Improve the ctags function regular expression.
Before it would only catch lines starting `fn` or `pub fn`.

Now it can cope with:

- attributes (e.g. `#[test] fn`)
- external functions (e.g. `extern fn`, `extern "C" fn`)
- unsafe functions (e.g. `unsafe fn`)

… and any correct combination of these
(e.g. `#[test] extern "C" unsafe fn`).
2014-02-27 21:04:04 -08:00
Kevin Ballard
ea0bd40d9b path: Implement windows::make_non_verbatim()
make_non_verbatim() takes a WindowsPath and returns a new one that does
not use the \\?\ verbatim prefix, if possible.
2014-02-27 21:04:04 -08:00
Kevin Ballard
af38726d8e path: clean up some lint warnings and an obsolete comment
Get rid of the unnecessary parenthesies that crept into some macros.
Remove a FIXME that was already fixed.
Fix a comment that wasn't rendering correctly in rustdoc.
2014-02-27 21:04:04 -08:00
Chris Morgan
498a6060ef Update Vim syntax file last change date. 2014-02-27 21:04:04 -08:00
Chris Morgan
879ac43689 Fix Vim section movements for standard Rust style.
(Expressed another way: make `[[` et al. work with the curly brace at
the end of a line as is standard Rust style, not just at the start is it
is by default in Vim, from K&R style.)

This came out of #11492, where a simpler but less effective technique
was initially proposed; some discussion of the techniques, ways and
means can be found there.

There are still a few caveats:

- Operator-pending mode behaves differently to the standard behaviour:
  if inside curly braces, it should delete up to and including the
  closing of the outermost curly brace (that doesn't seem to me
  consistent with documented behaviour, but it's what it does). Actual
  behaviour (the more logical and consistent, in my opinion): up to the
  start of the next outermost curly brace.

- With folding enabled (`set fdm=syntax`), `[[` and `]]` do not behave
  as they should: the default behaviour treats an entire closed fold as
  one line for these purposes while this code does not (I explicitly
  `set nofoldenable` in the function—the side-effects are worse with
  folds enabled), leading to unexpected behaviour, the worst of which is
  `[[` and/or `]]` not working in visual mode on a closed fold (visual
  mode keeps it at the extreme end of the region line of the folded
  region, so it's always going back to the opening line of that fold and
  immediately being shoved back to the end by visual mode).

- `[[` and `]]` are operating inside comments, whereas the standard
  behaviour skips comments.

- The viewport position is sometimes changed when it should not be
  necessary.
2014-02-27 21:04:04 -08:00
Chris Morgan
0a663a2d31 Update prelude items in Vim syntax. 2014-02-27 21:04:04 -08:00
Chris Morgan
eda5755a9d Downgrade do to a reserved keyword in Vim.
This means it gets highlighted as Error by default.
2014-02-27 21:04:04 -08:00
Chris Morgan
e0088ef80b Highlight the mod in extern mod x; as Error.
Just like the bare keyword `crate` is highlighted as Error (a little
dubious, actually, given macros), `mod` is invalid after `extern`: it's
obsolete syntax.
2014-02-27 21:04:03 -08:00
Chris Morgan
37f6564a84 Fix syntax::ext::deriving{,::*} docs formatting.
The most significant fix is for `syntax::ext::deriving::encodable`,
where one of the blocks of code, auspiciously containing `<S>` (recall
that Markdown allows arbitrary HTML to be contained inside it), was not
formatted as a code block, with a fun but messy effect.
2014-02-27 21:04:03 -08:00
Brian Anderson
c5fbc5048b rustc: Remove codemap and reachable from metadata encoder 2014-02-27 21:04:01 -08:00
Felix Crux
e3a251a410 Provide a more helpful error for tests that fail due to noexec
The rustdoc tests create and execute a file in a temporary directory. By
default on UNIX-like platforms this is in `/tmp`, which some users mount
with the `noexec` option. In those cases, the tests fail in a mysterious
way. This change adds a note that suggests what the problem might be, if
the error looks like it could have been caused by the `noexec` setup.

Closes #12558
2014-02-27 21:03:41 -08:00
Erick Tryzelaar
adeb730c77 std: cut down on the memory usage of SipHasher 2014-02-27 20:41:00 -08:00
Alex Crichton
cdc5729ea2 rustc: Move local native libs back in link-args
With linkers on unix systems, libraries on the right of the command line are
used to resolve symbols in those on the left of the command line. This means
that arguments must have a right-to-left dependency chain (things on the left
depend on things on the right).

This is currently done by ordering the linker arguments as

  1. Local object
  2. Local native libraries
  3. Upstream rust libraries
  4. Upstream native libraries

This commit swaps the order of 2 and 3 so upstream rust libraries have access to
local native libraries. It has been seen that some upstream crates don't specify
the library that they link to because the name varies per platform (e.g.
lua/glfw/etc).

This commit enables building these libraries by allowing the upstream rust crate
to have access to local native libraries. I believe that the failure mode for
this scheme is when an upstream rust crate depends on a symbol in an upstream
library which is then redefined in a local library. This failure mode is
incredibly uncommon, and the failure mode also varies per platform (OSX behaves
differently), so I believe that a change like this is fine to make.

Closes #12446
2014-02-27 19:59:02 -08:00
Brian Leibig
4d4ccb5d81 Make OS X installer build from /tmp/dist/pkgroot, and have it be part of the 'make dist' target 2014-02-27 19:59:02 -08:00
Brian Leibig
bbec2c54ed Add new target 'make dist-osx' to create a .pkg installer for OS X 2014-02-27 19:59:02 -08:00
Erick Tryzelaar
72b5e30f6c collections: allow HashMap to work with generic hashers 2014-02-27 19:02:52 -08:00
bors
700fd35fb9 auto merge of #11979 : FlaPer87/rust/static, r=nikomatsakis
This pull request partially addresses the 2 issues listed before. As part of the work required for this PR, `NonCopyable` was completely removed.

This PR also replaces the content of `type_is_pod` with `TypeContents::is_pod`, although `type_is_content` is currently not being used anywhere. I kept it for consistency with the other functions that exist in this module.

cc #10834
cc #10577

Proposed static restrictions
=====================

Taken from [this](https://github.com/mozilla/rust/pull/11979#issuecomment-35768249) comment.

I expect some code that, at a high-level, works like this:

- For each *mutable* static item, check that the **type**:
    - cannot own any value whose type has a dtor
    - cannot own any values whose type is an owned pointer
- For each *immutable* static item, check that the **value**:
      - does not contain any ~ or box expressions (including ~[1, 2, 3] sort of things, for now)
      - does not contain a struct literal or call to an enum variant / struct constructor where
          - the type of the struct/enum is freeze
          - the type of the struct/enum has a dtor
2014-02-27 18:51:53 -08:00
bors
f01a9a8d02 auto merge of #12584 : alexcrichton/rust/windows-files, r=brson
These commits fix handling of binary files on windows by using the raw `CreateFile` apis directly, also splitting out the windows/unix implementations to their own files because everything was configured between the two platforms.

With this fix in place, this also switches `rustc` to using libnative instead of libgreen. I have confirmed that this PR passes through try on all bots.
2014-02-27 14:56:56 -08:00
Alex Crichton
8c157ed63d native: Recognize EISDIR
This recognizes the EISDIR error code on both windows and unix platforms to
provide a more descriptive error condition.
2014-02-27 12:03:58 -08:00
Alex Crichton
40ab198356 rustc: Use libnative for the compiler
The compiler itself doesn't necessarily need any features of green threading
such as spawning tasks and lots of I/O, so libnative is slightly more
appropriate for rustc to use itself.

This should also help the rusti bot which is currently incompatible with libuv.
2014-02-27 12:03:58 -08:00
Alex Crichton
cd9010c77e native: Improve windows file handling
This commit splits the file implementation into file_unix and file_win32. The
two implementations have diverged to the point that they share almost 0 code at
this point, so it's easier to maintain as separate files.

The other major change accompanied with this commit is that file::open is no
longer based on libc's open function on windows, but rather windows's CreateFile
function. This fixes dealing with binary files on windows (test added in
previous commit).

This also changes the read/write functions to use ReadFile and WriteFile instead
of libc's read/write.

Closes #12406
2014-02-27 12:03:57 -08:00
Alex Crichton
843c5e6308 std: Small cleanup and test improvement
This weeds out a bunch of warnings building stdtest on windows, and it also adds
a check! macro to the io::fs tests to help diagnose errors that are cropping up
on windows platforms as well.

cc #12516
2014-02-27 12:03:57 -08:00
Flavio Percoco
59a04f5b12 Immutable static items should be Freeze Fixes #12432 2014-02-27 18:09:35 +01:00
Flavio Percoco
0c7a0125b4 Closes #7364 Test case 2014-02-27 18:09:35 +01:00
Flavio Percoco
49d5d70945 Closes #9243 Test case 2014-02-27 18:09:35 +01:00
Flavio Percoco
ee2f001a42 Forbid certain types for static items
- For each *mutable* static item, check that the **type**:
    - cannot own any value whose type has a dtor
    - cannot own any values whose type is an owned pointer

- For each *immutable* static item, check that the **value**:
    - does not contain any ~ or box expressions
        (including ~[1, 2, 3] sort of things)
    - does not contain a struct literal or call to an enum
        variant / struct constructor where
        - the type of the struct/enum has a dtor
2014-02-27 18:09:33 +01:00