Commit Graph

7506 Commits

Author SHA1 Message Date
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
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
Niko Matsakis
1b487a8906 Implement generalized object and type parameter bounds (Fixes #16462) 2014-08-27 21:46:52 -04:00
bors
c73ab0c10b auto merge of #16751 : luqmana/rust/tr, r=alexcrichton
Fixes #15562.
2014-08-27 09:31:14 +00:00
bors
5550edef46 auto merge of #16689 : wickerwaka/rust/crate-as, r=pcwalton
For review. Not sure about the link_attrs stuff. Will work on converting all the tests.

extern crate "foobar" as foo;
extern crate foobar as foo;

Implements remaining part of RFC #47.
Addresses issue #16461.

Removed link_attrs from rust.md, they don't appear to be supported by
the parser.
2014-08-27 06:01:18 +00:00
bors
566b470e13 auto merge of #16685 : alexcrichton/rust/remove-glob, r=brson
This library has been moved out to a cargo package in rust-lang.
2014-08-27 02:31:20 +00:00
Alex Crichton
118f481dbf glob: Deprecate the library in favor of cargo
This library has been moved out to a cargo package in rust-lang.
2014-08-26 17:54:58 -07:00
bors
e61ec99af2 auto merge of #16704 : flugsio/rust/fix-rustc-ice-lint-underscores-only, r=brson
Fix for type identifiers with only underscores (two or more), I assume they doesn't count as camel case.

```rust
type __ = int;

fn main() {
}
```

```
error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'index out of bounds: the len is 0 but the index is 0', /home/rustbuild/src/rust-buildbot/slave/nightly-linux/build/src/librustc/lib.rs:1

stack backtrace:
   1: 0xb603f5d0 - rt::backtrace:👿:write::ha55f265f6626471dmxr
   2: 0xb6042620 - failure::on_fail::h4d2c6d42b67e94803Sr
   3: 0xb640a180 - unwind::begin_unwind_inner::h484879fa7cc3611fZhe
   4: 0xb6409e50 - unwind::begin_unwind_fmt::hd14e5c64bc9006capfe
   5: 0xb6409df0 - rust_begin_unwind
   6: 0xb6454580 - failure::begin_unwind::h9ab1fc5753bd08f3YDk
   7: 0xb6458cb0 - failure::fail_bounds_check::h88167bad36865909aCk
   8: 0xb6f685d0 - lint::builtin::NonCamelCaseTypes.LintPass::check_item::check_case::he854eeffd105cb0f40E
   9: 0xb6f68050 - lint::builtin::NonCamelCaseTypes.LintPass::check_item::hc35b45d248e41cd43XE
  10: 0xb6f7b760 - lint::context::Context<'a>.Visitor<(*>::visit_item::closure.139262
  11: 0xb6f79510 - lint::context::Context<'a>::with_lint_attrs::hb9efe321fa321ce6spG
  12: 0xb6f81d30 - lint::context::Context<'a>.Visitor<(*>::visit_mod::he4593c831936b308ZMG
  13: 0xb6f8f2f0 - lint::context::check_crate::closure.139319
  14: 0xb6f79510 - lint::context::Context<'a>::with_lint_attrs::hb9efe321fa321ce6spG
  15: 0xb6efda70 - lint::context::check_crate::ha9e64328726b9579q1G
  16: 0xb6efda20 - driver::driver::phase_3_run_analysis_passes::closure.136263
  17: 0xb659d640 - util::common::time::h2837683151147173214
  18: 0xb6e7d130 - driver::driver::phase_3_run_analysis_passes::h7079eff53afc4de3Jfz
  19: 0xb6e783f0 - driver::driver::compile_input::h0ec84a550e24779cP1y
  20: 0xb6f26250 - driver::run_compiler::h7e7c01ecbfd0ad87JzC
  21: 0xb6f26150 - driver::main_args::closure.137215
  22: 0xb6f380d0 - task::TaskBuilder<S>::try_future::closure.138376
  23: 0xb6f37ec0 - task::TaskBuilder<S>::spawn_internal::closure.138353
  24: 0xb774bdd0 - task::spawn_opts::closure.8325
  25: 0xb6409c10 - unwind::try::try_fn::h91f00772748cf73eD8d
  26: 0xb6468ae0 - rust_try_inner
  27: 0xb6468aa0 - rust_try
  28: 0xb6407880 - unwind::try::h78a4fc0e85c326aef6d
  29: 0xb6407640 - task::Task::run::hb6f2d9484116e3d8xcd
  30: 0xb774bba0 - task::spawn_opts::closure.8271
  31: 0xb6409350 - thread::thread_start::h8c02fef9f651da5cjBd
  32: 0xb5ed3fc0 - start_thread
  33: 0xb62e8a32 - __clone
  34:        0x0 - <unknown>
```
2014-08-27 00:31:25 +00:00
bors
7932b719ec auto merge of #14397 : nick29581/rust/coerce, r=pnkfelix
DST coercions and DST fields in structs

The commits are not quite stand alone, I should probably squash them together before landing. In particular if you review the individual commits, then you'll see some scrappy stuff that gets fixed in later commits. But reading the commits in order might be easier to get an overall idea of what is going on.

The first commit includes putting back time zone into our time library - @pcwalton removed that as part of his de-~str'ing, but I had already converted it to use StrBuf, so we may as well leave it in. Update: no longer, this is removed in a later commit.
2014-08-26 10:31:06 +00:00
Nick Cameron
52ef46251e Rebasing changes 2014-08-26 16:07:32 +12:00
Nick Cameron
3e626375d8 DST coercions and DST structs
[breaking-change]

1. The internal layout for traits has changed from (vtable, data) to (data, vtable). If you were relying on this in unsafe transmutes, you might get some very weird and apparently unrelated errors. You should not be doing this! Prefer not to do this at all, but if you must, you should use raw::TraitObject rather than hardcoding rustc's internal representation into your code.

2. The minimal type of reference-to-vec-literals (e.g., `&[1, 2, 3]`) is now a fixed size vec (e.g., `&[int, ..3]`) where it used to be an unsized vec (e.g., `&[int]`). If you want the unszied type, you must explicitly give the type (e.g., `let x: &[_] = &[1, 2, 3]`). Note in particular where multiple blocks must have the same type (e.g., if and else clauses, vec elements), the compiler will not coerce to the unsized type without a hint. E.g., `[&[1], &[1, 2]]` used to be a valid expression of type '[&[int]]'. It no longer type checks since the first element now has type `&[int, ..1]` and the second has type &[int, ..2]` which are incompatible.

3. The type of blocks (including functions) must be coercible to the expected type (used to be a subtype). Mostly this makes things more flexible and not less (in particular, in the case of coercing function bodies to the return type). However, in some rare cases, this is less flexible. TBH, I'm not exactly sure of the exact effects. I think the change causes us to resolve inferred type variables slightly earlier which might make us slightly more restrictive. Possibly it only affects blocks with unreachable code. E.g., `if ... { fail!(); "Hello" }` used to type check, it no longer does. The fix is to add a semicolon after the string.
2014-08-26 12:38:51 +12:00
Nick Cameron
37a94b80f2 Use temp vars for implicit coercion to ^[T] 2014-08-26 12:37:45 +12:00
Luqman Aden
2ab4486cbb Add test. 2014-08-25 13:37:40 -07:00
Luqman Aden
395ef8ba1c Add tests to make sure intrinsicck doesn't apply to non-intrinsic fn's. 2014-08-25 12:48:35 -07:00
bors
5fb2dfaa20 auto merge of #16740 : alexcrichton/rust/issue-16725, r=pcwalton
Closes #16725
2014-08-25 12:10:56 +00:00
Alex Crichton
1c76d559c3 rustc: Encode the visibility of foreign items
The privacy pass of the compiler was previously not taking into account the
privacy of foreign items, or bindings to external functions. This commit fixes
this oversight by encoding the visibility of foreign items into the metadata for
each crate.

Any code relying on this will start to fail to  compile and the bindings must be
marked with `pub` to indicate that they can be used externally.

Closes #16725
[breaking-change]
2014-08-25 05:01:51 -07:00
bors
0b3e43d2a4 auto merge of #16699 : treeman/rust/issue-8492, r=alexcrichton
Closes #8492.

I did not find this suggestion in the [guidelines][] but it's mentioned in the [old style guide][].

[guidelines]: https://github.com/rust-lang/rust-guidelines
[old style guide]: 73c864a10a
2014-08-25 03:30:54 +00:00
Alex Crichton
fd763a5b1e native: clone/close_accept for win32 pipes
This commits takes a similar strategy to the previous commit to implement
close_accept and clone for the native win32 pipes implementation.

Closes #15595
2014-08-24 17:08:14 -07:00
Alex Crichton
110168de2a native: Implement clone/close_accept for unix
This commits implements {Tcp,Unix}Acceptor::{clone,close_accept} methods for
unix. A windows implementation is coming in a later commit.

The clone implementation is based on atomic reference counting (as with all
other clones), and the close_accept implementation is based on selecting on a
self-pipe which signals that a close has been seen.
2014-08-24 17:08:14 -07:00
bors
6d9b219e6f auto merge of #16646 : P1start/rust/trailing-commas, r=alexcrichton
This lets the parser understand trailing commas in method calls, method definitions, enum variants, and type parameters.

Closes #14240.
Closes #15887.
2014-08-24 22:16:00 +00:00
bors
9e8c30c553 auto merge of #16718 : Sawyer47/rust/bool-cast, r=pcwalton
Current version of rust fails when casting from bool, e.g.
```rust
fn main() {
    let _a = false as uint;
    let _b = true as uint;
    let _c: [bool, ..false as uint];
    let _d: [bool, ..true as uint];
    // _a and _b work, but _c and _d result in an error
    // error: expected constant expr for vector length: can't cast str to uint
}
```
This commit makes it work as expected.
2014-08-24 20:30:59 +00:00
Jonas Hietala
9968ae2554 Adjust the error messages to match the pattern "expected foo, found bar"
Closes #8492
2014-08-24 09:53:01 +02:00
bors
16d538cba0 auto merge of #16706 : pnkfelix/rust/fsk-fix-nojem-realloc, r=thestinger
Copy only up to `min(new_size, old_size)` when doing reallocate.

This was a bug when running with jemalloc disabled.

Fix #16687
2014-08-24 07:45:59 +00:00
Piotr Jawniak
46cf384ba9 Fix const evaluation of cast expression from bool 2014-08-24 09:14:41 +02:00
Jimmie Elvenmark
9eb9fcd719 lint: Improve camel case suggestion when empty. 2014-08-24 09:07:19 +02:00
bors
904d88c2be auto merge of #16697 : Sawyer47/rust/new-test, r=huonw
Closes #10618
Closes #16382
2014-08-24 01:25:57 +00:00
wickerwaka
c0e003d5ad extern crate foobar as foo;
Implements remaining part of RFC #47.
Addresses issue #16461.

Removed link_attrs from rust.md, they don't appear to be supported by
the parser.

Changed all the tests to use the new extern crate syntax

Change pretty printer to use 'as' syntax
2014-08-23 12:16:04 -07:00
Felix S. Klock II
b0b48511da Test case to illustate/reproduce bug. 2014-08-23 19:23:02 +02:00
bors
6843d8ccd5 auto merge of #16693 : vadimcn/rust/rename--win32, r=pcwalton 2014-08-23 14:30:57 +00:00
Jimmie Elvenmark
673c555443 librustc: Don't ICE with type when name only contain underscores. 2014-08-23 16:03:28 +02:00
Piotr Jawniak
ed18baeb49 Add test for #10618 and #16382
Closes #10618
Closes #16382
2014-08-23 12:31:48 +02:00
Vadim Chugunov
68811817f7 Complete renaming of win32 to windows 2014-08-23 02:11:28 -07:00
Vadim Chugunov
8c994a1237 Remove stage0 attributes. 2014-08-23 02:11:07 -07:00
bors
a284240783 auto merge of #16675 : luqmana/rust/pmu, r=alexcrichton
Fixes #16671.
2014-08-23 08:10:47 +00:00
Luqman Aden
f6dfff29ac Add tests. 2014-08-23 01:03:34 -07:00
bors
d0104d04fd auto merge of #16659 : brson/rust/slowparse, r=alexcrichton
Note that this contains a 9.5MB test file, but it should compress thoroughly.
2014-08-22 20:25:49 +00:00
P1start
fde41a3f70 Add support for trailing commas in more places
This lets the parser understand trailing commas in method calls, method
definitions, enum variants, and type parameters.

Closes #14240.
Closes #15887.
2014-08-23 07:23:51 +12:00
bors
c9cf3b3cc4 auto merge of #16655 : pcwalton/rust/unboxed-closures-unboxing-shims, r=luqmana
Closes #16591.

r? @luqmana
2014-08-22 13:35:51 +00:00
bors
5fe5e3947b auto merge of #16639 : pcwalton/rust/unboxed-closures-param-resolution, r=nick29581
Closes #16508.

r? @nick29581
2014-08-22 06:50:56 +00:00
Patrick Walton
24a2137269 librustc: Consider where clauses when traversing free regions in
signatures.

Closes #16549.
Closes #16564.
2014-08-21 19:33:29 -07:00
Brian Anderson
f59cfd9711 Use only 400000 characters to test slow string parsing. 2014-08-21 16:25:04 -07:00
Brian Anderson
a614f2820f syntax: Test parsing of long binary strings 2014-08-21 16:23:02 -07:00
bors
b43596b43e auto merge of #16637 : pcwalton/rust/unboxed-closures-expected-tuple, r=pnkfelix
code wasn't considering the zero-argument case.

Closes #16168.

r? @pnkfelix
2014-08-21 23:10:59 +00:00
Brian Anderson
bc7a85de29 syntax: Fix complexity of string parsing. Closes #16624. 2014-08-21 15:47:39 -07:00
bors
f92015f71b auto merge of #16499 : cmr/rust/struct-undef-repr, r=pcwalton
r? @pcwalton
2014-08-21 17:30:57 +00:00
Patrick Walton
6049b628ad librustc: Create unboxing shims as necessary for unboxed closures.
Closes #16591.
2014-08-21 10:05:28 -07:00
bors
4444aec142 auto merge of #16632 : pcwalton/rust/unboxed-closures-euv, r=luqmana
expression use visitor.

Closes #16166.

r? @huonw
2014-08-21 14:40:57 +00:00
bors
6f1b1a65ef auto merge of #16631 : pcwalton/rust/unboxed-closures-wrong-trait, r=huonw
the right trait and take the method name into account.

Closes #16599.

r? @huonw
2014-08-21 12:55:54 +00:00