Commit Graph

31886 Commits

Author SHA1 Message Date
Alex Crichton e442406dd7 rollup merge of #16726 : tshepang/consistency 2014-08-30 23:45:44 -07:00
Alex Crichton 941b06b0bd rollup merge of #16721 : tshepang/convenience 2014-08-30 23:45:41 -07:00
Alex Crichton 9fc29f1d2e rollup merge of #16716 : tshepang/temp 2014-08-30 23:45:37 -07:00
bors c2564540de auto merge of #16393 : SimonSapin/rust/patch-9, r=steveklabnik 2014-08-30 23:51:25 +00:00
bors 23c1f9b3c2 auto merge of #16873 : alexcrichton/rust/ignore-deadlocks, r=sfackler
This test apparently keeps making no progress and timing out builds on the OSX
builder, so this commit is switching the test to be ignored.

cc #16872
2014-08-30 21:51:25 +00:00
bors f297366593 auto merge of #16859 : alexcrichton/rust/snapshots, r=huonw 2014-08-30 19:51:25 +00:00
bors cbacdbc5f3 auto merge of #16598 : bkoropoff/rust/import-shadow-name, r=alexcrichton
This partially alleviates the confusing behavior in issue #16597
2014-08-30 12:41:22 +00:00
bors d398eb76ae auto merge of #16419 : huonw/rust/pretty-expanded-hygiene, r=pnkfelix
Different Identifiers and Names can have identical textual representations, but different internal representations, due to the macro hygiene machinery (syntax contexts and gensyms). This provides a way to see these internals by compiling with `--pretty expanded,hygiene`.

This is useful for debugging & hacking on macros (e.g. diagnosing https://github.com/rust-lang/rust/issues/15750/https://github.com/rust-lang/rust/issues/15962 likely would've been faster with this functionality).

E.g. 

```rust
#![feature(macro_rules)]
// minimal junk
#![no_std]

macro_rules! foo {
    ($x: ident) => { y + $x }
}

fn bar() {
    foo!(x)
}
```
```rust
#![feature(macro_rules)]
// minimal junk
#![no_std]


fn bar /* 61#0 */() { y /* 60#2 */ + x /* 58#3 */ }
```
2014-08-30 10:51:26 +00:00
bors 43c26e6041 auto merge of #16190 : Pythoner6/rust/labeled-while-loop, r=alexcrichton
Fixes #12643

> Say!
> I like labelled breaks/continues!

I will use them with a `for` loop.
And I will use with a `loop` loop.
Say! I will use them ANYWHERE!
… _even_ in a `while` loop.

Because they're now supported there.
2014-08-30 09:01:20 +00:00
Huon Wilson 32e437161d rustc: implement a pretty mode to print ident/name's ctxt & gensyms.
`--pretty expanded,hygiene` is helpful with debugging macro issues,
since two identifiers/names can be textually the same, but different
internally (resulting in weird "undefined variable" errors).
2014-08-30 16:50:38 +10:00
Alex Crichton e29059f508 test: Ignore a deadlocking test on OSX
This test apparently keeps making no progress and timing out builds on the OSX
builder, so this commit is switching the test to be ignored.

cc #16872
2014-08-29 23:25:35 -07:00
Tshepang Lekhonkhobe d89b2a5c3d doc: make docs build
Addresses this comment:
https://github.com/rust-lang/rust/pull/16721#issuecomment-53946624
2014-08-30 08:02:40 +02:00
bors c8e86e977f auto merge of #16322 : michaelwoerister/rust/gdb-pretty, r=alexcrichton
Also extends the autotest framework to let a test case choose if pretty printing should be enabled.
2014-08-30 04:01:24 +00:00
Joseph Martin e76db8ebc2 Fixed missing use statement 2014-08-29 23:44:21 -04:00
Pythoner6 aec34d8f26 Fix formatting, update copyright dates 2014-08-29 23:44:08 -04:00
Pythoner6 373b9d6243 Add support for labeled while loops. 2014-08-29 23:43:55 -04:00
bors 5419b2ca2c auto merge of #15773 : P1start/rust/style-lints, r=alexcrichton
This unifies the `non_snake_case_functions` and `uppercase_variables` lints into one lint, `non_snake_case`. It also now checks for non-snake-case modules. This also extends the non-camel-case types lint to check type parameters, and merges the `non_uppercase_pattern_statics` lint into the `non_uppercase_statics` lint.

Because the `uppercase_variables` lint is now part of the `non_snake_case` lint, all non-snake-case variables that start with lowercase characters (such as `fooBar`) will now trigger the `non_snake_case` lint.

New code should be updated to use the new `non_snake_case` lint instead of the previous `non_snake_case_functions` and `uppercase_variables` lints. All use of the `non_uppercase_pattern_statics` should be replaced with the `non_uppercase_statics` lint. Any code that previously contained non-snake-case module or variable names should be updated to use snake case names or disable the `non_snake_case` lint. Any code with non-camel-case type parameters should be changed to use camel case or disable the `non_camel_case_types` lint.

This also adds support for lint groups to the compiler. Lint groups are a way of grouping a number of lints together under one name. For example, this also defines a default lint for naming conventions, named `bad_style`. Writing `#[allow(bad_style)]` is equivalent to writing `#[allow(non_camel_case_types, non_snake_case, non_uppercase_statics)]`. These lint groups can also be defined as a compiler plugin using the new `Registry::register_lint_group` method.

This also adds two built-in lint groups, `bad_style` and `unused`. The contents of these groups can be seen by running `rustc -W help`.

[breaking-change]
2014-08-29 22:16:20 +00:00
Alex Crichton d15d559739 Register new snapshots 2014-08-29 14:33:08 -07:00
P1start ed2aad8b43 Add lint groups; define built-in lint groups `bad_style` and `unused`
This adds support for lint groups to the compiler. Lint groups are a way of
grouping a number of lints together under one name. For example, this also
defines a default lint for naming conventions, named `bad_style`. Writing
`#[allow(bad_style)]` is equivalent to writing
`#[allow(non_camel_case_types, non_snake_case, non_uppercase_statics)]`. These
lint groups can also be defined as a compiler plugin using the new
`Registry::register_lint_group` method.

This also adds two built-in lint groups, `bad_style` and `unused`. The contents
of these groups can be seen by running `rustc -W help`.
2014-08-30 09:12:04 +12:00
P1start de7abd8824 Unify non-snake-case lints and non-uppercase statics lints
This unifies the `non_snake_case_functions` and `uppercase_variables` lints
into one lint, `non_snake_case`. It also now checks for non-snake-case modules.
This also extends the non-camel-case types lint to check type parameters, and
merges the `non_uppercase_pattern_statics` lint into the
`non_uppercase_statics` lint.

Because the `uppercase_variables` lint is now part of the `non_snake_case`
lint, all non-snake-case variables that start with lowercase characters (such
as `fooBar`) will now trigger the `non_snake_case` lint.

New code should be updated to use the new `non_snake_case` lint instead of the
previous `non_snake_case_functions` and `uppercase_variables` lints. All use of
the `non_uppercase_pattern_statics` should be replaced with the
`non_uppercase_statics` lint. Any code that previously contained non-snake-case
module or variable names should be updated to use snake case names or disable
the `non_snake_case` lint. Any code with non-camel-case type parameters should
be changed to use camel case or disable the `non_camel_case_types` lint.

[breaking-change]
2014-08-30 09:10:05 +12:00
bors bd159d3867 auto merge of #15955 : nikomatsakis/rust/issue-5527-new-inference-scheme, r=pcwalton
The inference scheme proposed in <http://smallcultfollowing.com/babysteps/blog/2014/07/09/an-experimental-new-type-inference-scheme-for-rust/>.

This is theoretically a [breaking-change]. It is possible that you may encounter type checking errors, particularly related to closures or functions with higher-ranked lifetimes or object types. Adding more explicit type annotations should help the problem. However, I have not been able to make an example that *actually* successfully compiles with the older scheme and fails with the newer scheme.

f? @pcwalton, @pnkfelix
2014-08-29 19:21:12 +00:00
bors 51d0d06410 auto merge of #16767 : SiegeLord/rust/reexported_methods, r=cmr
Previously, this caused methods of re-exported types to not be inserted into
the search index. This fix may introduce some false positives, but in my
testing they appear as orphaned methods and end up not being inserted into the
final search index at a later stage.

Fixes issue #11943
2014-08-29 15:41:20 +00:00
Niko Matsakis 6e27c2fd58 Label FIXMEs with a bug number 2014-08-29 10:21:54 -04:00
Niko Matsakis 4c01251416 Introduce new inference scheme: variables are now instantiated with at most one type, and region variables are introduced as needed 2014-08-29 10:21:54 -04:00
bors 602592675c auto merge of #16838 : nick29581/rust/dst-bug-4, r=pnkfelix,nikomatsakis
Don't double free embedded, unsized slices.

Merge/rebase error from DST. Thanks to @eddyb for finding.

Closes #16826 (I hope)

r?
2014-08-29 13:56:29 +00:00
bors f6a7ab40e8 auto merge of #16762 : huonw/rust/for-error-nice, r=alexcrichton
- print the type of `x` in `for ... in x` in the "does not implement Iterator" message
- avoid printing that message if `x` has a type error
2014-08-29 08:21:26 +00:00
Huon Wilson ddc8cc92c9 rustc: remove a trait that is unnecessary after pretty move.
The type in the `impl` is now in the module with the trait.
2014-08-29 18:05:26 +10:00
Huon Wilson 149032aff3 rustc: move pretty printing into its own module.
There's a lot of it, and it's a fairly well-defined/separate chunk of
code, so it might as well be separate.
2014-08-29 18:05:26 +10:00
Nick Cameron 415d7e8ae9 Don't double free embedded, unsized slices
Thanks to @eddyb for finding the bug.

Closes #16826 (I hope)
2014-08-29 19:49:01 +12:00
Huon Wilson fd278a892a Avoid flow-on Iterator error for `for ... in [ty err] {}`.
This squashes the

> `for` loop expression has type `[type error]` which does not implement
> the `Iterator` trait

message that one received when writing `for ... in x` where was
previously found to have a type error.

Fixes #16042.
2014-08-29 17:43:46 +10:00
Huon Wilson 2e4a21c2c2 Mention type of `for` exprs that don't implement Iterator.
This improves the error message by telling the user the exact type of
`x` if it doesn't implement `Iterator` in `for ... in x {}`.

Closes #16043.
2014-08-29 17:39:09 +10:00
bors e3549ee202 auto merge of #16770 : cburgdorf/rust/patch_overloaded_calls_hint, r=alexcrichton 2014-08-29 04:56:18 +00:00
bors dee8423531 auto merge of #16768 : nham/rust/libcollections_test_cleanup, r=alexcrichton
unused imports.

This is mostly converting uses of `push_back`, `pop_back`, `shift` and `unshift` to `push`, `pop`, `remove` and `insert`.
2014-08-29 02:26:28 +00:00
Niko Matsakis d6e5797e41 Introduce snapshot_vec abstraction 2014-08-28 21:15:23 -04:00
bors 2e92c67dc0 auto merge of #16664 : aturon/rust/stabilize-option-result, r=alexcrichton
Per API meeting

  https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-13.md

# Changes to `core::option`

Most of the module is marked as stable or unstable; most of the unstable items are awaiting resolution of conventions issues.

However, a few methods have been deprecated, either due to lack of use or redundancy:

* `take_unwrap`, `get_ref` and `get_mut_ref` (redundant, and we prefer for this functionality to go through an explicit .unwrap)
* `filtered` and `while`
* `mutate` and `mutate_or_set`
* `collect`: this functionality is being moved to a new `FromIterator` impl.

# Changes to `core::result`

Most of the module is marked as stable or unstable; most of the unstable items are awaiting resolution of conventions issues.

* `collect`: this functionality is being moved to a new `FromIterator` impl.
* `fold_` is deprecated due to lack of use
* Several methods found in `core::option` are added here, including `iter`, `as_slice`, and variants.

Due to deprecations, this is a:

[breaking-change]
2014-08-28 23:56:20 +00:00
bors 1a33d7a541 auto merge of #16626 : ruud-v-a/rust/duration-reform, r=brson
This changes the internal representation of `Duration` from

    days: i32,
    secs: i32,
    nanos: u32

to

    secs: i64,
    nanos: i32

This resolves #16466. Note that `nanos` is an `i32` and not `u32` as suggested, because `i32` is easier to deal with, and it is not exposed anyway. Some methods now take `i64` instead of `i32` due to the increased range. Some methods, like `num_milliseconds`, now return an `Option<i64>` instead of `i64`, because the range of `Duration` is now larger than e.g. 2^63 milliseconds.

A few remarks:
- Negating `MIN` is impossible. I chose to return `MAX` as `-MIN`, but it is one nanosecond less than the actual negation. Is this the desired behaviour?
- In `std::io::timer`, some functions accept a `Duration`, which is internally converted into a number of milliseconds. However, the range of `Duration` is now larger than 2^64 milliseconds. There is already a FIXME in the file that this should be addressed (without a ticket number though). I chose to silently use 0 ms if the duration is too long. Is that right, as long as the backend still uses milliseconds?
- Negative durations are not formatted correctly, but they were not formatted correctly before either.
2014-08-28 22:11:18 +00:00
Ruud van Asseldonk 447b64ebc2 libstd: Wrap duration.rs at 100 characters. 2014-08-28 21:56:27 +02:00
Niko Matsakis 790d9c4708 Refactor and cleanup inference code: s/get_ref()/fields/, use try! macro rather than if_ok! 2014-08-28 14:37:35 -04:00
bors ba39b50943 auto merge of #16553 : nick29581/rust/log, r=huon
When specifying RUST_LOG, the programmer may append `/regex` to the end of the spec. All results will then be filtered using that regex.

r?
2014-08-28 18:36:29 +00:00
Niko Matsakis ae314512e3 Fix kindck to consider inherited bounds 2014-08-28 14:15:34 -04:00
Niko Matsakis 1c15e9efeb Fix regionck to account for the uniqueness requirements on ref mut reborrows 2014-08-28 14:15:34 -04:00
Niko Matsakis f60a7c4798 Fix regionck to consider bounds on a proc when capturing variables 2014-08-28 14:15:32 -04:00
Aaron Turon 9a8233d377 stabilize core::result
Per API meeting

  https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-13.md

Most of the module is marked as stable or unstable; most of the unstable
items are awaiting resolution of conventions issues.

* `collect`: this functionality is being moved to a new `FromIterator`
  impl.
* `fold_` is deprecated due to lack of use
* Several methods found in `core::option` are added here, including
  `iter`, `as_slice`, and variants.

Due to deprecations, this is a:

[breaking-change]
2014-08-28 09:12:54 -07:00
Aaron Turon 276b8b125d Fallout from stabilizing core::option 2014-08-28 09:12:54 -07:00
Aaron Turon 3a52ef4613 stabilize core::option
Per API meeting

  https://github.com/rust-lang/meeting-minutes/blob/master/Meeting-API-review-2014-08-13.md

Most of the module is marked as stable or unstable; most of the unstable
items are awaiting resolution of conventions issues.

However, a few methods have been deprecated, either due to lack of use
or redundancy:

* `take_unwrap`, `get_ref` and `get_mut_ref` (redundant, and we prefer
  for this functionality to go through an explicit .unwrap)
* `filtered` and `while`
* `mutate` and `mutate_or_set`
* `collect`: this functionality is being moved to a new `FromIterator`
  impl.

Due to deprecations, this is a:

[breaking-change]
2014-08-28 09:12:54 -07:00
bors b5165321e4 auto merge of #16453 : nikomatsakis/rust/type-bounds-3, r=pcwalton
Implements https://github.com/rust-lang/rfcs/pull/192.

In particular:

1. type parameters can have lifetime bounds and objects can close over borrowed values, presuming that they have suitable bounds.
2. objects must have a bound, though it may be derived from the trait itself or from a `Send` bound.
3. all types must be well-formed.
4. type parameters and lifetime parameters may themselves have lifetimes as bounds. Something like `T:'a` means "the type T outlives 'a`" and something like `'a:'b`" means "'a outlives 'b". Outlives here means "all borrowed data has a lifetime at least as long".

This is a [breaking-change]. The most common things you have to fix after this change are:

1. Introduce lifetime bounds onto type parameters if your type (directly or indirectly) contains a reference. Thus a struct like `struct Ref<'a, T> { x: &'a T }` would be changed to `struct Ref<'a, T:'a> { x: &'a T }`.
2. Introduce lifetime bounds onto lifetime parameters if your type contains a double reference. Thus a type like `struct RefWrapper<'a, 'b> { r: &'a Ref<'b, int> }` (where `Ref` is defined as before) would need to be changed to `struct RefWrapper<'a, 'b:'a> { ... }`.
2. Explicitly give object lifetimes in structure definitions. Most commonly, this means changing something like `Box<Reader>` to `Box<Reader+'static>`, so as to indicate that this is a reader without any borrowed data. (Note: you may wish to just change to `Box<Reader+Send>` while you're at it; it's a more restrictive type, technically, but means you can send the reader between threads.)

The intuition for points 1 and 2 is that a reference must never outlive its referent (the thing it points at). Therefore, if you have a type `&'a T`, we must know that `T` (whatever it is) outlives `'a`. And so on.

Closes #5723.
2014-08-28 15:01:39 +00:00
Niko Matsakis 1b487a8906 Implement generalized object and type parameter bounds (Fixes #16462) 2014-08-27 21:46:52 -04:00
Nick Cameron cc9b2b0550 Allow a regex filter for RUST_LOG
When specifying RUST_LOG, the programmer may append `/regex` to the end of the spec. All results will then be filtered using that regex.
2014-08-28 10:14:57 +12:00
bors 0d3bd7720c auto merge of #16757 : steveklabnik/rust/lets_not_lie_in_the_concurrency_guide, r=alexcrichton
This cleans up blatant lies in the concurrency guide, and modernizes it
a bit. There's a lot more to do, but until I get to it, let's make it a
little bit better.
2014-08-27 21:31:13 +00:00
Steve Klabnik 263d65cb01 Fix lies in the concurrency guide.
This cleans up blatant lies in the concurrency guide, and modernizes it
a bit. There's a lot more to do, but until I get to it, let's make it a
little bit better.
2014-08-27 16:42:24 -04:00