Commit Graph

29925 Commits

Author SHA1 Message Date
Patrick Walton
654d6444fe libsyntax: Disallow struct literals after if, while, match, and
`for...in`.

Closes #14803.

If you used a structure literal after one of these keywords, surround it
in parentheses.

[breaking-change]
2014-06-23 15:39:29 -07:00
bors
575710f6ce auto merge of #15106 : Sawyer47/rust/rm-duplicated-tests, r=alexcrichton
Even if they used to test different things in the past, they are
now identical to other files.

Closes #11496
2014-06-23 16:16:37 +00:00
bors
d77cb22bb6 auto merge of #15100 : rapha/rust/master, r=alexcrichton
/usr/bin/env appears to be more portable.
2014-06-23 14:31:39 +00:00
bors
baa72085f4 auto merge of #15098 : ben0x539/rust/nullary-tuple-struct, r=pcwalton
Reject `struct Foo();` to fix #15095.
2014-06-23 12:46:33 +00:00
bors
4362db0d68 auto merge of #15089 : tomjakubowski/rust/rustdoc-default-typarams-12291, r=alexcrichton
fix #12291
2014-06-23 11:01:36 +00:00
bors
9a583bb931 auto merge of #15086 : jakub-/rust/xc-struct-variants-match, r=alexcrichton
Turns out field names of struct variants are not encoded in crate metadata.
2014-06-23 09:16:36 +00:00
bors
1efc02a9ec auto merge of #15083 : edwardw/rust/destructure-trait-ref, r=pcwalton
Closes #15031.
2014-06-23 07:26:37 +00:00
bors
c6f86e41a1 auto merge of #15061 : pnkfelix/rust/fsk-fix-issue-10846, r=nikomatsakis
In other words, Late-bound regions that occur non-free should be
skipped.

Fix #10846 (specifically the ICE, not the weakness in the current type inference).
2014-06-23 04:31:35 +00:00
bors
5971193332 auto merge of #15097 : tomjakubowski/rust/fix-feature-gate-docs, r=sfackler
See http://static.rust-lang.org/doc/master/rustc/front/feature_gate/index.html for the problem this fixes.
2014-06-23 02:21:37 +00:00
bors
1c7b780787 auto merge of #15068 : erickt/rust/mem-inline, r=pcwalton
This is a couple micro-optimizations I've been sitting on for a while. This inlines a couple functions that are important to the `std::io::mem`. Ultimately, this results in about a 15% performance increase in some micro-benchmarks for my [libserialize](https://github.com/erickt/rust-serde) rewrite.
2014-06-23 00:11:39 +00:00
Raphael Speyer
53ec4a6732 Change /bin/env to /usr/bin/env in helper python script, as it is more portable 2014-06-23 09:17:40 +10:00
bors
ca3e557ee8 auto merge of #15081 : jakub-/rust/issue-15080, r=alexcrichton
Fixes #15080.
2014-06-22 21:31:39 +00:00
bors
34bd169171 auto merge of #15091 : nikomatsakis/rust/issue-5527-rename-types, r=pcwalton
Some cleanups I'm sick of rebasing.

r? @pcwalton (do you agree with new names?)
2014-06-22 18:41:41 +00:00
Benjamin Herr
ff50ce9a1b libsyntax: don't allow enum structs with no fields
Unit-like structs are written as `struct Foo;`, but we erroneously
accepted `struct Foo();` and took it to mean the same thing. Now we
don't, so use the `struct Foo;` form!

[breaking-change]
2014-06-22 20:21:11 +02:00
Tom Jakubowski
ffcc443098 librustc: Fix poorly formatted doc in feature_gate
The #![feature(...)] line had been rendering in the docs as a header
because of Markdown syntax.
2014-06-22 10:29:42 -07:00
bors
c9f3c68961 auto merge of #15088 : Sawyer47/rust/detotal, r=alexcrichton
There were still Total{Ord,Eq} in docs and src/etc
2014-06-22 15:16:39 +00:00
Niko Matsakis
8a4bb8a576 Rename ty_param_bounds_and_ty to Polytype 2014-06-22 10:25:11 -04:00
Niko Matsakis
7ead6bed48 Rename and move ty_param_substs_and_ty 2014-06-22 10:25:11 -04:00
Piotr Jawniak
37b8ce0064 Remove duplicated test files
Even if they used to test different things in the past, they are
now identical to other files.

Closes #11496
2014-06-22 15:55:27 +02:00
Piotr Jawniak
0b9e4fcaff Update few files after comparison traits renaming
There were still Total{Ord,Eq} in docs and src/etc
2014-06-22 09:31:39 +02:00
Felix S. Klock II
36caa7a729 RegionFolder should only invoke callback on free regions.
In other words, Late-bound regions that occur non-free should be
skipped.

Fix #10846.
2014-06-22 06:19:56 +02:00
bors
4c39962d32 auto merge of #15005 : dotdash/rust/i1_bool, r=alexcrichton
We currently compiled bools to i8 values, because there was a bug in
LLVM that sometimes caused miscompilations when using i1 in, for
example, structs.

Using i8 means a lot of unnecessary zero-extend and truncate operations
though, since we have to convert the value from and to i1 when using for
example icmp or br instructions. Besides the unnecessary overhead caused
by this, it also sometimes made LLVM miss some optimizations.

First, we have to fix some bugs concerning the handling of
attributes in foreign function declarations and calls. These
are required because the i1 type needs the ZExt attribute when
used as a function parameter or return type.

Then we have to update LLVM to get a bugfix without which LLVM
sometimes generates broken code when using i1.

And then, finally, we can switch bools over to i1.
2014-06-22 00:01:34 +00:00
Jakub Wieczorek
26e692dd39 Fix spurious non-exhaustive errors for cross-crate struct variants 2014-06-21 23:54:48 +02:00
Erick Tryzelaar
b9aeda4802 collections: fix running make check-stage1-collections 2014-06-21 17:42:22 -04:00
Erick Tryzelaar
0f39dc7b78 std: inline many of the Writer/Reader methods
This allows llvm to optimize away much of the overhead from using
the MemReader/MemWriters. My benchmarks showed it to shave 15% off
of my in progress serialization/json encoding.
2014-06-21 17:42:22 -04:00
Erick Tryzelaar
76371d1ff1 serialize: Simplify the json docs 2014-06-21 17:42:22 -04:00
Erick Tryzelaar
b0fb520f72 std: micro-optimize Vec constructors and add benchmarks
Generally speaking, inlining doesn't really help out with
constructing vectors, except for when we construct a zero-sized
vector. This patch allows llvm to optimize this case away in
a lot of cases, which shaves off 4-8ns. It's not much, but it
might help in some inner loop somewhere.

before:

running 12 tests
test bench_extend_0          ... bench:       123 ns/iter (+/- 6)
test bench_extend_5          ... bench:       323 ns/iter (+/- 11)
test bench_from_fn_0         ... bench:         7 ns/iter (+/- 0)
test bench_from_fn_5         ... bench:        49 ns/iter (+/- 6)
test bench_from_iter_0       ... bench:        11 ns/iter (+/- 0)
test bench_from_iter_5       ... bench:       176 ns/iter (+/- 11)
test bench_from_slice_0      ... bench:         8 ns/iter (+/- 1)
test bench_from_slice_5      ... bench:        73 ns/iter (+/- 5)
test bench_new               ... bench:         0 ns/iter (+/- 0)
test bench_with_capacity_0   ... bench:         6 ns/iter (+/- 1)
test bench_with_capacity_100 ... bench:        41 ns/iter (+/- 3)
test bench_with_capacity_5   ... bench:        40 ns/iter (+/- 2)

after:

test bench_extend_0          ... bench:       123 ns/iter (+/- 7)
test bench_extend_5          ... bench:       339 ns/iter (+/- 27)
test bench_from_fn_0         ... bench:         7 ns/iter (+/- 0)
test bench_from_fn_5         ... bench:        54 ns/iter (+/- 4)
test bench_from_iter_0       ... bench:        11 ns/iter (+/- 1)
test bench_from_iter_5       ... bench:       182 ns/iter (+/- 16)
test bench_from_slice_0      ... bench:         4 ns/iter (+/- 0)
test bench_from_slice_5      ... bench:        62 ns/iter (+/- 3)
test bench_new               ... bench:         0 ns/iter (+/- 0)
test bench_with_capacity_0   ... bench:         0 ns/iter (+/- 0)
test bench_with_capacity_100 ... bench:        41 ns/iter (+/- 1)
test bench_with_capacity_5   ... bench:        41 ns/iter (+/- 3)
2014-06-21 17:42:22 -04:00
Edward Wang
f87bc6a5d1 Make destructuring trait reference work
Closes #15031.
2014-06-22 04:03:15 +08:00
Jakub Wieczorek
d4da4ba4b2 Fix a #14731 regression in missing_constructor() for vector patterns
Fixes #15080.
2014-06-21 20:36:17 +02:00
Björn Steinbrink
d747de5a92 Compile bools to i1
We currently compiled bools to i8 values, because there was a bug in
LLVM that sometimes caused miscompilations when using i1 in, for
example, structs.

Using i8 means a lot of unnecessary zero-extend and truncate operations
though, since we have to convert the value from and to i1 when using for
example icmp or br instructions. Besides the unnecessary overhead caused
by this, it also sometimes made LLVM miss some optimizations.

Fixes #8106.
2014-06-21 19:59:58 +02:00
Björn Steinbrink
90a9f65b8d Update LLVM
To fix #8106, we need an LLVM version that contains r211082 aka 0dee6756
which fixes a bug that blocks that issue.

There have been some tiny API changes in LLVM, and cmpxchg changed its
return type. The i1 part of the new return type is only interesting when
using the new weak cmpxchg, which we don't do.
2014-06-21 19:59:58 +02:00
Björn Steinbrink
5e720aac42 Add missing attributes to indirect calls for foreign functions
When calling a foreign function, some arguments and/or return value
attributes are required to conform to the foreign ABI. Currently those
attributes are only added to the declaration of foreign functions. With
direct calls, this is no problem, because LLVM can see that those
attributes apply to the call. But with an indirect call, LLVM cannot do
that and the attribute is missing.

To fix that, we have to add those attribute to the calls to foreign
functions as well.

This also allows to remove the special handling of the SRet attribute,
which is ABI-dependent and will be set via the `attr` field of the
return type's `ArgType`.
2014-06-21 19:59:58 +02:00
Björn Steinbrink
abdbaa2e19 Correctly set return type attributes on foreign function declarations
The ArgType type gives us a generic way to specify an attribute for a
type to ensure ABI conformance for foreign functions. But the code that
actually sets the argument attributes in the function declaration
only sets the attribute for the return type when the type is indirect.

Since LLVMAddAttribute() doesn't allow to set attributes on the return
type, we have to use LLVMAddFunctionAttribute() instead.

This didn't cause problems yet, because currently only some indirect
types require attributes to be set.
2014-06-21 19:59:57 +02:00
bors
db9af1d505 auto merge of #15074 : conradkleinespel/rust/master, r=pcwalton
Using something like:

```rust
box "string"
```

yields
```shell
"`~\"string\"` has been removed; use `\"string\".to_string()` instead"
```

Should the error message maybe say `box "string"` instead?
2014-06-21 17:31:32 +00:00
bors
f556c8cbd8 auto merge of #15062 : pcwalton/rust/trailing-plus, r=brson
This will break code that looks like `Box<Trait+>`. Change that code to
`Box<Trait>` instead.

Closes #14925.

[breaking-change]

r? @brson
2014-06-21 15:36:39 +00:00
Tom Jakubowski
94bace795d rustdoc: show default type parameters in generics
fix #12291
2014-06-21 05:03:33 -07:00
Conrad Kleinespel
8bcfabaeac replace reference to ~"string" with box "string" 2014-06-21 12:31:10 +02:00
bors
0ae4b97c09 auto merge of #15029 : aturon/rust/stability-index, r=brson
This commit makes several changes to the stability index infrastructure:

* Stability levels are now inherited lexically, i.e., each item's
  stability level becomes the default for any nested items.

* The computed stability level for an item is stored as part of the
  metadata. When using an item from an external crate, this data is
  looked up and cached.

* The stability lint works from the computed stability level, rather
  than manual stability attribute annotations. However, the lint still
  checks only a limited set of item uses (e.g., it does not check every
  component of a path on import). This will be addressed in a later PR,
  as part of issue #8962.

* The stability lint only applies to items originating from external
  crates, since the stability index is intended as a promise to
  downstream crates.

* The "experimental" lint is now _allow_ by default. This is because
  almost all existing crates have been marked "experimental", pending
  library stabilization. With inheritance in place, this would generate
  a massive explosion of warnings for every Rust program.

  The lint should be changed back to deny-by-default after library
  stabilization is complete.

* The "deprecated" lint still warns by default.

The net result: we can begin tracking stability index for the standard
libraries as we stabilize, without impacting most clients.

Closes #13540.
2014-06-21 04:01:25 +00:00
bors
b1646cbfd9 auto merge of #14731 : jakub-/rust/pattern-matching-refactor, r=alexcrichton
This PR is changing the error messages for non-exhaustive pattern matching to include a more accurate witness, i.e. a pattern that is not covered by any of the ones provided by the user. Example:

```rust
fn main() {
	match (true, (Some("foo"), [true, true]), Some(42u)) {
		(false, _, _) => (),
		(true, (None, [true, _]), None) => (),
		(true, (None, [false, _]), Some(1u)) => ()
	}
}
```

```sh
/tmp/witness.rs:2:2: 6:3 error: non-exhaustive patterns: (true, (core::option::Some(_), _), _) not covered
/tmp/witness.rs:2 	match (true, (Some("foo"), [true, true]), Some(42u)) {
/tmp/witness.rs:3 		(false, _, _) => (),
/tmp/witness.rs:4 		(true, (None, [true, _]), None) => (),
/tmp/witness.rs:5 		(true, (None, [false, _]), Some(1u)) => ()
/tmp/witness.rs:6 	}
```

As part of that, I refactored some of the relevant code and carried over the changes to fixed vectors from the previous PR.

I'm putting it out there for now but the tests will be red.
2014-06-21 02:11:22 +00:00
Patrick Walton
ae067477fb libsyntax: Stop parsing + with no bounds after it.
This will break code that looks like `Box<Trait+>`. Change that code to
`Box<Trait>` instead.

Closes #14925.

[breaking-change]
2014-06-20 15:46:58 -07:00
bors
2563481ca9 auto merge of #14988 : pcwalton/rust/unsafe-destructor-feature-gate, r=alexcrichton
Closes #8142.

This is not the semantics we want long-term. You can continue to use
`#[unsafe_destructor]`, but you'll need to add
`#![feature(unsafe_destructor)]` to the crate attributes.

[breaking-change]

r? @alexcrichton
2014-06-20 21:31:22 +00:00
Patrick Walton
dcbf4ec2a1 librustc: Put #[unsafe_destructor] behind a feature gate.
Closes #8142.

This is not the semantics we want long-term. You can continue to use
`#[unsafe_destructor]`, but you'll need to add
`#![feature(unsafe_destructor)]` to the crate attributes.

[breaking-change]
2014-06-20 14:24:31 -07:00
Jakub Wieczorek
a88819adbe Ignore issue-14393 on Windows 2014-06-20 23:07:22 +02:00
bors
43d1938260 auto merge of #15056 : alexcrichton/rust/issue-15043, r=kballard
The parser already has special logic for parsing `>` tokens from `>>`, and this
commit extends the logic to the acquiring a `>` from the `>=` and `>>=` tokens
as well.

Closes #15043
2014-06-20 17:06:19 +00:00
Alex Crichton
f0c730b819 syntax: Parse GT tokens from >= and >>=
The parser already has special logic for parsing `>` tokens from `>>`, and this
commit extends the logic to the acquiring a `>` from the `>=` and `>>=` tokens
as well.

Closes #15043
2014-06-20 09:53:12 -07:00
Jakub Wieczorek
abce42afa3 Address review comments 2014-06-20 17:41:19 +02:00
Jakub Wieczorek
76f7eeef52 Fix #14393
String patterns should have a single constructor of arity 0.
2014-06-20 17:08:57 +02:00
Jakub Wieczorek
9dca26cf92 Add unreachability detection for missized patterns of fixed size vectors
Fixed #13482
2014-06-20 17:08:57 +02:00
Jakub Wieczorek
1e68d57682 Add support for fixed size vectors in let/arg patterns
Fixes #7784
2014-06-20 17:08:57 +02:00
Jakub Wieczorek
34407dcdbb Provide a witness pattern for non-exhaustive patterns
Fixed #4321
2014-06-20 17:08:57 +02:00