Commit Graph

52650 Commits

Author SHA1 Message Date
mrmiywj
201d9ed0bb add help on pattern guard
fix too long column

fix typo of help on pattern guard

one nit

fix compile fail
2016-05-03 10:00:51 +08:00
bors
4751e45521 Auto merge of #33208 - nrc:save-json, r=pnkfelix
save-analysis: dump in JSON format

cc #18582
2016-04-28 05:47:57 -07:00
bors
0f9ba99291 Auto merge of #33161 - jseyfried:parse_tuple_struct_field_vis, r=nikomatsakis
Parse `pub(restricted)` visibilities on tuple struct fields

Parse `pub(restricted)` on tuple struct fields (cc #32409).

r? @nikomatsakis
2016-04-28 03:38:04 -07:00
bors
009a64916e Auto merge of #32980 - Aatch:better-mir-building, r=nagisa
Various improvements to MIR and LLVM IR Construction

Primarily affects the MIR construction, which indirectly improves LLVM
IR generation, but some LLVM IR changes have been made too.

* Handle "statement expressions" more intelligently. These are
  expressions that always evaluate to `()`. Previously a temporary would
  be generated as a destination to translate into, which is unnecessary.

  This affects assignment, augmented assignment, `return`, `break` and
  `continue`.
* Avoid inserting drops for non-drop types in more places. Scheduled
  drops were already skipped for types that we knew wouldn't need
  dropping at construction time. However manually-inserted drops like
  those for `x` in `x = y;` were still generated. `build_drop` now takes
  a type parameter like its `schedule_drop` counterpart and checks to
  see if the type needs dropping.

* Avoid generating an extra temporary for an assignment where the types
  involved don't need dropping. Previously an expression like
  `a = b + 1;` would result in a temporary for `b + 1`. This is so the
  RHS can be evaluated, then the LHS evaluated and dropped and have
  everything work correctly. However, this isn't necessary if the `LHS`
  doesn't need a drop, as we can just overwrite the existing value.

* Improves lvalue analysis to allow treating an `Rvalue::Use` as an
  operand in certain conditions. The reason for it never being an
  operand is so it can be zeroed/drop-filled, but this is only true for
  types that need dropping.

The first two changes result in significantly fewer MIR blocks being
generated, as previously almost every statement would end up generating
a new block due to the drop of the `()` temporary being generated.
2016-04-28 01:26:45 -07:00
bors
cf3970aac5 Auto merge of #33151 - ollie27:rustdoc_abi, r=alexcrichton
rustdoc: Cleanup ABI rendering

Use a common method for rendering `extern "<abi>"`.

This now consistently shows `extern fn` rather than `extern "C" fn`.
2016-04-27 23:16:41 -07:00
bors
435095f32a Auto merge of #32791 - LeoTestard:feature-gate-clean, r=nikomatsakis
Feature gate clean

This PR does a bit of cleaning in the feature-gate-handling code of libsyntax. It also fixes two bugs (#32782 and #32648). Changes include:

* Change the way the existing features are declared in `feature_gate.rs`. The array of features and the `Features` struct are now defined together by a single macro. `featureck.py` has been updated accordingly. Note: there are now three different arrays for active, removed and accepted features instead of a single one with a `Status` item to tell wether a feature is active, removed, or accepted. This is mainly due to the way I implemented my macro in the first time and I can switch back to a single array if needed. But an advantage of the way it is now is that when an active feature is used, the parser only searches through the list of active features. It goes through the other arrays only if the feature is not found. I like to think that error checking (in this case, checking that an used feature is active) does not slow down compilation of valid code. :) But this is not very important...
* Feature-gate checking pass now use the `Features` structure instead of looking through a string vector. This should speed them up a bit. The construction of the `Features` struct should be faster too since it is build directly when parsing features instead of calling `has_feature` dozens of times.
* The MacroVisitor pass has been removed, it was mostly useless since the `#[cfg]-stripping` phase happens before (fixes #32648). The features that must actually be checked before expansion are now checked at the time they are used. This also allows us to check attributes that are generated by macro expansion and not visible to MacroVisitor, but are also removed by macro expansion and thus not visible to PostExpansionVisitor either. This fixes #32782. Note that in order for `#[derive_*]` to be feature-gated but still accepted when generated by `#[derive(Trait)]`, I had to do a little bit of trickery with spans that I'm not totally confident into. Please review that part carefully. (It's in `libsyntax_ext/deriving/mod.rs`.)::

Note: this is a [breaking change], since programs with feature-gated attributes on macro-generated macro invocations were not rejected before. For example:

```rust
macro_rules! bar (
    () => ()
);

macro_rules! foo (
    () => (
        #[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
        bar!();
    );
);
```
foo!();
2016-04-27 18:35:29 -07:00
James Miller
5bda576cd6 Factor out function call checking to a helper method
The logic for checking `call` and `invoke` instructions was duplicated
between them, so factor it out to a helper method.
2016-04-28 13:18:51 +12:00
James Miller
b5d7783546 Check when building invoke as well as calls
LLVM's assertion doesn't provide much insight as to what the problem
was. We were already checking `call` instructions ourselves, so this
brings the checks from there to `invoke`.

Both the `invoke` and `call` checking is controlled by
`debug_assertions`.
2016-04-28 13:18:51 +12:00
James Miller
3bcee269b5 Handle immediate tuples in trans_arguments_untupled
Use either getelementptr or extractvalue depending on whether or not the
tuple is immediate or not.
2016-04-28 13:18:51 +12:00
James Miller
0e3b37a52e Fix codegen-units tests
I'm not sure what the signficance of `drop-glue i8` is, nor why one of
the tests had it appear while the others had it disappear. Either way it
doesn't seem like the presence or absense of it is the focus of the
tests.
2016-04-28 13:18:51 +12:00
James Miller
c55d9e591b Move zero-sized type handling logic to new_operand
`new_operand` now checks the type it's given and either creates the nil
value itself, or produces an empty operand.
2016-04-28 13:18:51 +12:00
James Miller
89edd96be8 Fix translation of Assign/AssignOp as rvalues
In code like `let x = y = z;`, `y = z` goes through `as_rvalue`, which
didn't handle it. Now it translates the assignment and produces `()`
directly.
2016-04-28 13:18:51 +12:00
James Miller
869172305f Fixup tests
The drop glue for `i8` is no longer generated as a trans item
2016-04-28 13:18:51 +12:00
James Miller
c2de80f05f Address comments
Moves `stmt_expr` into its own module, `expr::stmt`.
2016-04-28 13:18:51 +12:00
James Miller
f242fe3c04 Various improvements to MIR and LLVM IR Construction
Primarily affects the MIR construction, which indirectly improves LLVM
IR generation, but some LLVM IR changes have been made too.

* Handle "statement expressions" more intelligently. These are
  expressions that always evaluate to `()`. Previously a temporary would
  be generated as a destination to translate into, which is unnecessary.

  This affects assignment, augmented assignment, `return`, `break` and
  `continue`.
* Avoid inserting drops for non-drop types in more places. Scheduled
  drops were already skipped for types that we knew wouldn't need
  dropping at construction time. However manually-inserted drops like
  those for `x` in `x = y;` were still generated. `build_drop` now takes
  a type parameter like its `schedule_drop` counterpart and checks to
  see if the type needs dropping.
* Avoid generating an extra temporary for an assignment where the types
  involved don't need dropping. Previously an expression like
  `a = b + 1;` would result in a temporary for `b + 1`. This is so the
  RHS can be evaluated, then the LHS evaluated and dropped and have
  everything work correctly. However, this isn't necessary if the `LHS`
  doesn't need a drop, as we can just overwrite the existing value.
* Improves lvalue analysis to allow treating an `Rvalue::Use` as an
  operand in certain conditions. The reason for it never being an
  operand is so it can be zeroed/drop-filled, but this is only true for
  types that need dropping.

The first two changes result in significantly fewer MIR blocks being
generated, as previously almost every statement would end up generating
a new block due to the drop of the `()` temporary being generated.
2016-04-28 13:17:43 +12:00
Jeffrey Seyfried
78a8127ff0 Add tests 2016-04-27 23:40:46 +00:00
bors
cda7c1cf24 Auto merge of #33199 - mitaa:tokenize-responsibly, r=nrc
Make some fatal lexer errors recoverable

I've kept the changes to a minimum since I'm not really sure if this approach is a acceptable.

fixes #12834

cc @nrc
2016-04-27 13:49:45 -07:00
mitaa
6887202ea3 Make some fatal lexer errors recoverable 2016-04-27 20:48:18 +02:00
Oliver Middleton
48aabbd9e3 rustdoc: Render extern fn instead of extern "C" fn 2016-04-27 18:43:51 +01:00
Nick Cameron
7ca2b9461f Review changes and satisfy make tidy 2016-04-28 05:24:54 +12:00
bors
b52d76a085 Auto merge of #33214 - oli-obk:const_err_var_exprs, r=eddyb
report `const_err` on all expressions that can fail

also a drive-by fix for reporting an "overflow in shift *left*" when shifting an `i64` *right*

This increases the warning noise for shifting by more than the bitwidth and for `-T::MIN`. I can silence the bitwidth warnings explicitly and fix the const evaluator to make sure `--$expr` is treated exactly like `$expr` (which is kinda wrong, but mathematically right).

r? @eddyb
2016-04-27 04:00:16 -07:00
Oliver Schneider
5cdcad9d35 update Cargo.toml for rustbuild 2016-04-27 10:47:46 +02:00
bors
80bff1eea7 Auto merge of #33226 - fabricedesre:update-llvm, r=alexcrichton
Update llvm to 751345228a0ef03fd147394bb5104359b7a808be

Picking up the changes from 751345228a

r? @alexcrichton
2016-04-26 22:47:40 -07:00
Fabrice Desré
1d2846dcda Update llvm to 751345228a0ef03fd147394bb5104359b7a808be 2016-04-26 17:03:14 -07:00
bors
8f55218189 Auto merge of #31414 - durka:clone-copy, r=alexcrichton
special-case #[derive(Copy, Clone)] with a shallow clone

If a type is Copy then its Clone implementation can be a no-op. Currently `#[derive(Clone)]` generates a deep clone anyway. This can lead to lots of code bloat.

This PR detects the case where Copy and Clone are both being derived (the general case of "is this type Copy" can't be determined by a syntax extension) and generates the shallow Clone impl. Right now this can only be done if there are no type parameters (see https://github.com/rust-lang/rust/issues/31085#issuecomment-178988663), but this restriction can be removed after specialization.

Fixes #31085.
2016-04-26 14:54:37 -07:00
bors
897199a0fb Auto merge of #33191 - alexcrichton:rustdoc-create-dir-all-racy, r=steveklabnik
rustdoc: Handle concurrent mkdir requests

It's likely that `rustdoc` as a tool is run concurrently in the same output
(e.g. documenting multiple crates as Cargo does), in which case it needs to
handle concurrent calls to `fs::create_dir`.
2016-04-26 12:00:35 -07:00
Alex Burka
9249e6a1e2 shallow Clone for #[derive(Copy,Clone)]
Changes #[derive(Copy, Clone)] to use a faster impl of Clone when
both derives are present, and there are no generics in the type.

The faster impl is simply returning *self (which works because the
type is also Copy). See the comments in libsyntax_ext/deriving/clone.rs
for more details.

There are a few types which are Copy but not Clone, in violation
of the definition of Copy. These include large arrays and tuples. The
very existence of these types is arguably a bug, but in order for this
optimization not to change the applicability of #[derive(Copy, Clone)],
the faster Clone impl also injects calls to a new function,
core::clone::assert_receiver_is_clone, to verify that all members are
actually Clone.

This is not a breaking change, because pursuant to RFC 1521, any type
that implements Copy should not do any observable work in its Clone
impl.
2016-04-26 13:49:29 -04:00
bors
01a0207919 Auto merge of #33142 - tshepang:split-long-line, r=guillaumegomez
doc: that line was too long
2016-04-26 09:04:27 -07:00
bors
092b0738b7 Auto merge of #33203 - Ryman:patch-3, r=alexcrichton
libstd: fix typos in thread::LocalKey docs
2016-04-26 06:57:03 -07:00
Oliver Schneider
d3c489c917 don't demote expressions just because const_eval fails
this might introduce subtle bugs to code generation
2016-04-26 15:32:18 +02:00
Oliver Schneider
9d7ed99c06 skip non-const-path errors for now
Associated constants aren't implemented fully in early const eval
2016-04-26 14:11:14 +02:00
Oliver Schneider
89d1046503 don't report bitshift overflow twice 2016-04-26 14:10:07 +02:00
Oliver Schneider
735c018974 skip double negation in const eval 2016-04-26 14:09:05 +02:00
bors
03bef4c43b Auto merge of #32989 - GuillaumeGomez:e0393, r=Manishearth
Add E0393 error explanation

Part of #32777.

r? @Manishearth
cc @steveklabnik
2016-04-26 04:51:08 -07:00
bors
81d070f582 Auto merge of #32962 - taralx:patch-1, r=GuillaumeGomez
Clean up some info log spam.

Some of this looks like merge cruft, but the region spam is especially noisy.
2016-04-26 02:42:52 -07:00
Oliver Schneider
3acee3b6c5 const_err lint all constant expressions 2016-04-26 11:18:48 +02:00
Oliver Schneider
ee983230c9 report shift right error instead of shift left error on right shift 2016-04-26 11:17:32 +02:00
Guillaume Gomez
d648fc6865 Add E0393 error explanation 2016-04-26 11:16:36 +02:00
bors
769ac42c2e Auto merge of #33099 - eddyb:issue-33096, r=michaelwoerister
Normalize types before using them in debuginfo.

Small oversight, fixes #33096 - odd thing is that the old code doesn't look like it should've ever worked, although it wasn't using all of the type parameters, so maybe that's what changed.
2016-04-26 00:36:03 -07:00
bors
41028def11 Auto merge of #33204 - Manishearth:rollup, r=Manishearth
Rollup of 7 pull requests

- Successful merges: #33107, #33133, #33160, #33167, #33194, #33196, #33200
- Failed merges:
2016-04-25 22:26:56 -07:00
bors
8ce735858d Auto merge of #33210 - alexcrichton:fix-ndk-dir, r=alexcrichton
mk: Fix use of deprecated configure var

The `--android-cross-path` has been deprecated for some time now, we should use
`CFG_ARM_LINUX_ANDROIDEABI_NDK` instead.

Ideally this would use the right triple, but we're only testing ARM for now.
2016-04-25 18:48:05 -07:00
Alex Crichton
1fac8a4564 mk: Fix use of deprecated configure var
The `--android-cross-path` has been deprecated for some time now, we should use
`CFG_ARM_LINUX_ANDROIDEABI_NDK` instead.

Ideally this would use the right triple, but we're only testing ARM for now.
2016-04-25 18:35:58 -07:00
Nick Cameron
f7652bf809 save-analysis-json: lower def ids 2016-04-26 10:31:48 +12:00
Nick Cameron
e1d61cb637 save-analysis: expand smoke test to cover json and csv formats 2016-04-26 10:16:44 +12:00
Nick Cameron
5065f0c2a2 save-analysis-json: thread through -z option
In fact, we make JSOn the default and add an option for save-analysis-csv for the legacy behaviour.

We also rename some bits and pieces `dxr` -> `save-analysis`
2016-04-26 10:14:44 +12:00
Manish Goregaokar
3dc0b55a47 Rollup merge of #33200 - sfackler:nonblocking-docs, r=alexcrichton
Fix reference to TCP in UDP docs

Closees #33195
2016-04-26 01:44:52 +05:30
Manish Goregaokar
edbb0d5a90 Rollup merge of #33196 - mitaa:rdoc-crate-links, r=alexcrichton
rustdoc: Linkify extern crates

fixes #33178

r? @alexcrichton
2016-04-26 01:44:52 +05:30
Manish Goregaokar
b50a2ff4d1 Rollup merge of #33194 - mitaa:rdoc-a, r=alexcrichton
rustdoc: Improve accessibility of rustdoc pages

fixes #33131

r? @alexcrichton
2016-04-26 01:44:52 +05:30
Manish Goregaokar
4c0fdebe7b Rollup merge of #33167 - benaryorg:master, r=alexcrichton
clarify documentation of TcpStream::connect() for multiple valid addresses

I am not sure how the UDP part of the stdlib behaves when passing multiple valid addresses, but it should be mentioned as there are legit use cases for [`impl<'a> ToSocketAddrs for &'a [SocketAddr]`](http://doc.rust-lang.org/nightly/std/net/trait.ToSocketAddrs.html), a TCP fallback only being one.

Just a little example program for anyone willing to enhance the documentation further:

```rust
use std::net::SocketAddr;
use std::net::ToSocketAddrs;
use std::net::TcpStream;

fn main()
{
	let v: Vec<SocketAddr> = vec!
	[
		"127.0.0.1:1338".to_socket_addrs().unwrap().next().unwrap(),
		"127.0.0.1:1337".to_socket_addrs().unwrap().next().unwrap(),
		"127.0.0.1:1339".to_socket_addrs().unwrap().next().unwrap(),
	];

	let stream = TcpStream::connect(&v[..]).unwrap();
}
```
2016-04-26 01:44:51 +05:30
Manish Goregaokar
b588f6903d Rollup merge of #33160 - euclio:rustdoc-unstable-deprecated, r=alexcrichton
show unstable status for deprecated items

Fixes #32374.
2016-04-26 01:44:51 +05:30