Commit Graph

52623 Commits

Author SHA1 Message Date
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
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
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
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
Manish Goregaokar
5fba2bfa0a Rollup merge of #33133 - mitaa:rdoc-smth-smth-impl, r=alexcrichton
rustdoc: inline all the impls

This used to be done to avoid inlining impls referencing private items, but is now unnecessary since we actually check that impls do not reference non-doc-reachable items.

fixes #32881
fixes #33025
fixes #33113

r? @alexcrichton
2016-04-26 01:44:51 +05:30
Manish Goregaokar
1bc30a5621 Rollup merge of #33107 - sanxiyn:prev-impl-item, r=eddyb
Show previous definition of duplicate impl item

Fix #32971.
2016-04-26 01:44:51 +05:30
Ryman
2b71219a61 libstd: fix typos in thread::LocalKey docs 2016-04-25 21:01:19 +01:00
bors
bd938166d6 Auto merge of #33115 - mbrubeck:vfp3-d16, r=nrc
Enable vfp3-d16 for ARMv7 Android target

Android's [armeabi-v7a ABI][1] guarantees at least VFPv3-d16 hardware FPU support, so Rust should include this in the default features for the `arm-linux-androideabi` target.

[1]: https://developer.android.com/ndk/guides/abis.html
2016-04-25 10:43:36 -07:00
Steven Fackler
379e6fc5be Fix reference to TCP in UDP docs
Closees #33195
2016-04-25 09:12:51 -07:00
bors
90318b8c22 Auto merge of #32258 - nikomatsakis:fewer-errors, r=arielb1
Suppress fallback and ambiguity errors

If the infcx has observed other errors, then suppress both default type
parameter fallback (which can be unreliable, as the full constraint set
is not available) and errors related to unresovled
variables (annoyingly, integer type variables cannot currently be
unified with error, so that has to be a separate mechanism). Also add a
flag to `infcx` to allow us to independently indicate when we have
observed an error and hence should trigger this suppression mode.

Fixes #31997

cc @alexcrichton
r? @arielb1
2016-04-25 08:13:22 -07:00
Niko Matsakis
b3d54a2c0e patch test due to changes from compiletest-json 2016-04-25 09:38:06 -04:00
bors
cfae4dea87 Auto merge of #33184 - tamird:misc-cleanup, r=alexcrichton
librustc_back: misc cleanup

r? @alexcrichton
2016-04-25 05:45:52 -07:00
mitaa
0b5b782e39 Linkify extern crates on rustdoc pages 2016-04-25 11:26:33 +02:00
mitaa
bb9ec82563 Improve accessibility of rustdoc pages 2016-04-25 07:50:16 +02:00
Alex Crichton
36d9ee3da9 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-24 21:37:22 -07:00
bors
253b7c1e1a Auto merge of #33120 - tclfs:patch-2, r=Manishearth
docs: Highlight a keyword
2016-04-24 20:17:08 -07:00
bors
645dd013ac Auto merge of #33085 - fitzgen:make-enumerate-example-more-clear, r=steveklabnik
Make the `Iterator::enumerate` doc example more clear

The example uses integers for the value being iterated over, but the indices
added by `enumerate` are also integers, so I always end up double taking and
thinking harder than I should when parsing the documentation. I also always
forget which order the index and value are in the tuple so I frequently hit this
stumbling block. This commit changes the documentation to iterate over
characters so that it is immediately obvious which part of the tuple is the
index and which is the value.
2016-04-24 17:04:49 -07:00
Tamir Duberstein
847d195e3c librustc_back: fix typo 2016-04-24 19:39:02 -04:00
Tamir Duberstein
8c65ef7fa0 librustc_back: remove explicit linker
"cc" is already the default.
2016-04-24 19:39:01 -04:00
Tamir Duberstein
322f3a3eaa rustc: update Cargo.lock 2016-04-24 19:38:49 -04:00
bors
19304837c8 Auto merge of #33179 - Manishearth:breaking-batch, r=Manishearth
Batch up breaking libsyntax changes

Contains:

 - #33125
 - #33041
 - #33157

cc https://github.com/rust-lang/rust/issues/31645
2016-04-24 13:47:22 -07:00